General information
Category:
COM/DCOM and OLE Automation
Title:
Word Mail Merge from 97 to 2002
I have a VFP 6 SP3 app that I am testing with XP and Word 2002 SP2. Under ODBC DSN I have VFP Tables and Databases as an option. That does not seem to be the problem. The problem is that the connection between an existing mail merge document and data source seems to be lost. For new documents it works fine. But for existing documents (created in Word 97) I must reestablish the data souce and then save the document for the merge to work. I do not want my clients to have to reestablish the data source on each mail merge document. Any ideas?
goWordApp = createobject("Word.Application")
word_directory = AddBs(JustPath(ctemplate_name)) && returns 'c:\something\somethingelse\'
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
gowordapp.activedocument.mailmerge.destination = 0
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
goWordapp.ActiveDocument.MailMerge.OpenDataSource(cdatasource)
goWordapp.Activedocument.SaveAs(ctemplate_name)
endif
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only