Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
OpenDataSource each time Mail Merge Doc is opened?
Message
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01100186
Message ID:
01100825
Views:
14
Does anyone have experience with OpenDataSource and Word Mail Merge?


>This is my current code to launch a Word Mail Merge. Wondering if it would hurt anything to do the OpenDataSource every time, even for documents that already existed and had a datasource attached. It is a multi client environment. They each have their own data source, but they share the Mail Merge documents. Can I change the data source each time the document is opened?
>
>
>
>goWordApp = createobject("Word.Application")
>
>word_directory = AddBs(JustPath(ctemplate_name))
>goWordApp.ChangeFileOpenDirectory (word_directory)
>
>if file(ctemplate_name)
>goWordApp.Visible = .T.
>goWordApp.documents.open(ctemplate_name)
>gowordapp.Application.WindowState = 1
>gowordapp.activewindow.windowstate = 3 &&maximized
>
>if creccount != 0
>&& Word give an error if you try to merge and your datasource is empty
>gowordapp.activedocument.mailmerge.destination =
>0 && to a new document
>goWordApp.ActiveDocument.MailMerge.Execute
>endif
>else
>goWordApp.Visible = .T.
>gowordapp.Documents.Add
>gowordapp.Application.WindowState = 1
>gowordapp.activewindow.windowstate = 1 &&maximized
>
>goWordapp.ActiveDocument.MailMerge.MainDocumentType = 0
>&& set as a mail merge form document
>
>goWordapp.ActiveDocument.MailMerge.OpenDataSource(cdatasource) &&attach
>the mail merge document to the datasource
>goWordapp.Activedocument.SaveAs(ctemplate_name)
>endif
>if gowordapp.Application.WindowState <> 1
>gowordapp.activewindow.left = 0
>gowordapp.activewindow.top = 0
>endif
>
>ON ERROR &OldOnErr
>
>wait "" timeout 10 && give client time to click on word, so
>any messageboxes from realtrac will not make realtrac the active task
>
>release goWordApp
>
>
Previous
Reply
Map
View

Click here to load this message in the networking platform