Displaying Word Print Dialogue Box from VBA

Lstclair

New member
Local time
Today, 23:36
Joined
May 10, 2015
Messages
5
Hi,

Could someone assist with helping me to know the code for displaying the Word Print dialogue box instead of sending it straight to the printer.

I have the following code:

'Open Word
Set objWord = New Word.Application
'Letter document would be open
Set objletter = objWord.Documents.Open(strletterpath & strworddoc)
objletter.MailMerge.OpenDataSource (strletterpath & strletterfile)
objletter.MailMerge.Destination = wdSendToPrinter 'normally print
Dialogs(wdDialogFilePrint).Show
objletter.MailMerge.Execute
'not normally here
'objWord.Visible = True

This is to produce a mailmerge based upon a query.

Previously on Access 2000 and Word 2000 it would display the print dialogue box, but I am trying to upgrade it all to 2013 and this does not do it now with Access 2013 and Word 2013.

Thank you in advance.
 
Hi,

Could someone assist with helping me to know the code for displaying the Word Print dialogue box instead of sending it straight to the printer.

I have the following code:

'Open Word
Set objWord = New Word.Application
'Letter document would be open
Set objletter = objWord.Documents.Open(strletterpath & strworddoc)
objletter.MailMerge.OpenDataSource (strletterpath & strletterfile)
objletter.MailMerge.Destination = wdSendToPrinter 'normally print
Dialogs(wdDialogFilePrint).Show
objletter.MailMerge.Execute
'not normally here
'objWord.Visible = True

This is to produce a mailmerge based upon a query.

Previously on Access 2000 and Word 2000 it would display the print dialogue box, but I am trying to upgrade it all to 2013 and this does not do it now with Access 2013 and Word 2013.

Thank you in advance.

This code looks ok at first glance. To run it in Access 2013 you need to have Microsoft Word 14.0 Object Library turned on in References. Have you checked that ? If yes and the code still does not work, give us the error decription and the line where the error occurs.

Best,
Jiri
 
The code works fine. However it sends it straight to the default printer.

I need it to come up with the print options so I can select the printer to send it to and also then possible trays in the printer driver.
 
The code works fine. However it sends it straight to the default printer.

I need it to come up with the print options so I can select the printer to send it to and also then possible trays in the printer driver.

This line
Code:
Dialogs(wdDialogFilePrint).Show
should display the printer dialog. If it does not, the code does not work fine. There may have been a change in the syntax of the dialog that makes a Boolean function. In which case it should written as

Code:
If Dialogs(wdDialogFilePrint).Show = True Then 
..............
End If

try it ! At any rate, it should display the options.

Best,
Jiri
 

Users who are viewing this thread

Back
Top Bottom