Login
`
Templates, Tools and Utilities
|
||
Icetips Article
Back to article list
Search Articles
Add Comment
Printer friendly
Direct link
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
Today is November 21, 2024, 3:34 am This article has been viewed 35392 times. Google search has resulted in 234 hits on this article since January 25, 2004.
|
|