98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Printing in VBA
Printing in VBA
Resolved · Urgent Priority · Version 2003
Nick has attended:
Excel VBA Intro Intermediate course
Excel VBA Intro Intermediate course
Excel VBA Intro Intermediate course
Excel VBA Advanced course
Printing in VBA
The function .PrintOut will print the document to the default printer..... What is the code which will launch the print dialogue box and alow the user to select which printer to print the document to?
Thanks,
Nick Smith
RE: Printing in VBA
Hi Nick
Thank you for your question
Your best option would be to write a procedure that allows the user to specify which printer is to be the active printer.
I general i would populate a combo box with a list of the available printers and have the user select the printer there. I would then write code that allocates the value of the combo box to a string variable. I would then use this variable to specify the active printer.
The crucial line of code would be
application.activeprinter = strvariable
It is obviously important to correctly name the printers in the combo box
Regards
Stephen
RE: Printing in VBA
Thanks for the response Stephen...
The challenge with the combo box idea is that this code is to be used by 70 hotels around the country all with their own choices of networked printers..... Therefore i would be unable to source the addresses for each of the possible printer options.
Is there no code which would just launch the print dialogue box as if you had just clicked on the print button from the file menu?
Thanks,
Nick
RE: Printing in VBA
Hi Nick
Thanks for your reply. Sorry misunderstood precisely what you required
The following line of code will display the print dialog box
Application.Dialogs(xlDialogPrint).Show
Hope this helps. If you need anything else, please let me know
Regards
Stephen
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Copying the same value, label or formula quickly into a range of selected cells.Select your range of cells. Type the value, label or formula that you want to appear in all the selected cells and then press Ctrl+Enter. |