Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Suppressing printer dialogue in Word mailmerge

Status
Not open for further replies.

Mike Lewis

Programmer
Jan 10, 2003
17,516
Scotland
I am trying to do a Word mailmerge. I want to send the merged output to the printer, without user interaction.

This is my code (with non-essential stuff removed for clarity):

Code:
thisform.oDoc.MailMerge.OpenDataSource(lcDataFile)
thisform.oDoc.Mailmerge.Destination = 1 
    && 1 here means send mailmerge to the printer
thisform.oDoc.Mailmerge.Execute

This works OK, except for one detail. Because the mailmerge destination is the printer, Word opens it Printer dialogue so that the user can select the printer.

The trouble is that I am running this code with Word invisible. This means the user cannot see the dialogue and so the application appears to hang. In any case, I don't need the user to pick the printer, because I always want to use a specific printer.

My question is: How can I prevent Word displaying its printer dialogue during a mailmerge? I have tried setting the application object's ActivePrinter property, and have also set DisplayAlerts to 0, but these do not solve the problem.

Thanks in advance.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Dave has the right answer, I think. Merge to a new document and then print the document.

Tamar
 
Yep. Right after the merge, the result document is oWord.ActiveDocument.

Tamar
 
Tamar,

Right after the merge, the result document is oWord.ActiveDocument.

Of course.I should've have realised that.

It's now working, as follows:

Code:
thisform.oDoc.MailMerge.OpenDataSource(lcDataFile)
thisform.oDoc.Mailmerge.Destination = 0
    && 0 = send mailmerge to a new doc
thisform.oDoc.Mailmerge.Execute  
loNewDoc = thisform.oWord.ActiveDocument
loNewDoc.Printout()
loNewDoc.Close(0)

Thanks again for your help.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top