Mailmerge with Word - not waiting for user

Post Reply
Ollie
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

Mailmerge with Word - not waiting for user

Post by Ollie »

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

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()
 
Many thanks
Ollie.

Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)
User avatar
anserkk
Posts: 1280
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Mailmerge with Word - not waiting for user

Post by anserkk »

I have not tried Word MailMerge with an option to Wait for input from the user during the Merge Process.

From the Microsoft Help topic regarding oWord:ActiveDocument:MailMerge:Execute( .T. ) // Pause:=True:

"True for Microsoft Word pause and display a troubleshooting dialog box if a mail merge error is found. False to report errors in a new document"

You do not want to set this to true or the default; set it to FALSE.

I understand that to serve your purpose, you need to make use of the Ask and Fill-in Fields in a Word Mail Merge. I have not tried this.
The following link may be helpful
http://www.fontstuff.com/word/wordtut02.htm

Regards
Anser
Ollie
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

Re: Mailmerge with Word - not waiting for user

Post by Ollie »

Thanks for that - good advice then - I'll make it FALSE.

I can see how "Ask Fields" may work, but sometimes I want to merge just one document (so then Ask is ok), but other times, a whole mail merge - in which case "Ask" won't be very nice.

So the quest continues.

Ollie.
Many thanks
Ollie.

Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)
Post Reply