`
OLE/ActiveX: MS-Word mail-merge code 2004-07-05 -- Peter Kirk Newsgroups: softvelocity.clarion.language You could try turning off the DisplayAlerts flag.. (See below) I have included the entire text for my Word merge. It uses VBA and works well for me. (for clarification, I am using external merge files and routines stored in a common template which is loaded as an addin.) CASE CLIP(ContainerFile) OF 'Word.Document' !Merge Word Document WindowDisplayString = 'Merging Document...' DISPLAY() !Get Handle of Existing Applications WindowName = 'MICROSOFT WORD' !Window Caption DO SaveExistingApplications ?OBJ{PROP:Create} = 'Word.Application' ?OBJ{'AddIns.Add("'&CLIP(CommonTemplate)&'",'&vbTrue &')'}!Load Common Template ?OBJ{'Visible'} = vbTrue vbApp = ?OBJ{'Documents.Add("'&CLIP(TemplateToLoad)&'")'} IF MacroToRun <> '' THEN ?OBJ{'Run("'&CLIP(MacroToRun)&'")'} !Run Macro END ?OBJ{'ActiveDocument.AttachedTemplate'} = '""' !Remove Attached Template ?OBJ{'ActiveDocument.SaveAs(FileName="'&CLIP(TempContainerFile)&'")'} IF ?OBJ{'Documents.Count'} > 0 THEN !Are Any Documents Open? LOOP i# = 1 to ?OBJ{'Documents.Count'} !Close All Open Documents ?OBJ{'Documents('&i# &').Saved'} = vbTrue ?OBJ{'Documents('&i# &').Close('&vbFalse &')'} !Close Don't Save END END WindowDisplayString = 'Loading Document...' DISPLAY() ?OBJ{'AddIns("'&CLIP(CommonTemplate)&'").Installed'} = vbFalse !Remove AddIn ?OBJ{'DisplayAlerts'} = vbFalse ?OBJ{'Quit('&vbFalse &')'} !Quit, Don't Save ?OBJ{'DisplayAlerts'} = vbTrue ?OBJ{PROP:Release} = vbApp ?OBJ{PROP:DeActivate} = TRUE !DeActivate Word Object !ShutDown Open Process (If Still active for any reason) DO ShutDownOpenProcesses !Terminate Word Application END Regards, Peter Kirk Printed November 21, 2024, 4:22 pm This article has been viewed/printed 35393 times. Google search has resulted in 234 hits on this article since January 25, 2004. |