General information
Category:
COM/DCOM and OLE Automation
Title:
Problem with Automating MailMerge Setup
I have a program (listed below) which creates a Word object, opens a document and adds a data source for a mail merge. When I run a macro in Word which does the same thing it works fine. But when I run my program, it sets up the mailmerge OK but displays a "Confirm Data Source" Screen, where it waits for me to select the FoxPro Files - Word" option. I don't understand why it works fine as a macro in word, but not when ran in VFP. I created the VFP code from the macro.destdir = "Q:\appsdev\vers2.0\graphletter\data\00004459"
** Program
m.letter = "H2RA_TI_LETTER_OPTION1.DOC"
m.mletter = "lMMERGE.DBF"
newLetter = destdir + "\" + m.letter
newMerge = destdir + "\" + m.mletter
x1 = CREATEOBJECT("Word.Application")
x1.Documents.Open(newLetter)
x1.Visible = .T.
x1.ActiveDocument.MailMerge.MainDocumentType = -1
x1.ActiveDocument.MailMerge.MainDocumentType = 0
connStr = "DSN=FoxPro Files - Word;UID=;PWD=;SourceDB=" + destdir + ";SourceType=DBF;Exclusive=No;" + ;
"BackgroundFetch=Yes;Collate=MACHINE;Null=Yes;Deleted=Yes;"
** OPen DataSource format (name, format, ConfirmConversions, **ReadOnly, LinkToSource, AddToRecentFiles,
** PasswordDocument, PasswordTemplate, Revert, WritePasswordDocument, **WritePasswordTemplate, Connection
x1.ActiveDocument.MailMerge.OpenDataSource(newMerge,0,0,0,1,0, , , , connStr)
x1.ActiveDocument.MailMerge.EditMainDocument
x1.ActiveDocument.Save
x1.ActiveDocument.Close
x1.Quit
Thanks
Becky
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