Mailmerge with Word - not waiting for user

Mailmerge with Word - not waiting for user

Postby Ollie » 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


Code: Select all  Expand view
     
      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)
Ollie
 
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

Re: Mailmerge with Word - not waiting for user

Postby anserkk » Wed Feb 29, 2012 6:53 am

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
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Mailmerge with Word - not waiting for user

Postby Ollie » Wed Feb 29, 2012 5:02 pm

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)
Ollie
 
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Silvio.Falconi and 117 guests