Mailmerge with Word - not waiting for user
Posted: Wed Feb 29, 2012 5:08 am
I am sending an email using word. I would like it to stop in the email (allow the user to make any changes) and then hit send.
The code below doesn't wait for the user - it just sends it.
How can I make it wait for the user?
I thought it has to so with this line, but .T. or .F. behaves the same: oWord:ActiveDocument:MailMerge:Execute( .T. ) // Pause:=True
The code below doesn't wait for the user - it just sends it.
How can I make it wait for the user?
I thought it has to so with this line, but .T. or .F. behaves the same: oWord:ActiveDocument:MailMerge:Execute( .T. ) // Pause:=True
Code: Select all
oWord := CREATEOBJECT( "Word.Application" )
oDoc := oWord:Documents:Open( cDocument )
oDoc:MailMerge:MainDocumentType := 0 //wdFormLetters=0 // sets the mail merge main document type
oDoc:MailMerge:EditMainDocument()
oDoc:MailMerge:OpenDataSource( cDatafile ) //"c:\moredata.txt")
oDoc:MailMerge:Destination := 2 //Email
oDoc:MailMerge:SuppressBlankLines := .T.
oDoc:MailMerge:DataSource:FirstRecord := 1 // wdDefaultFirstRecord = 1
oDoc:MailMerge:DataSource:LastRecord := - 16 //wdDefaultLastRecord = -16
oDoc:MailMerge:MailAddressFieldName = "EMAIL"
oDoc:MailMerge:MailSubject = cSubject
oWord:ActiveDocument:MailMerge:Execute( .T. ) // Pause:=True
oDoc:Close( 0 )
oWord:Quit()