|
Forum home »
Delegate support and help forum »
Microsoft Excel VBA Training and Help » Printing in VBA
Printing in VBA
The UK's most regular instructor-led training courses.
Training information: excel training in uk
· Excel-courses-london
· VBA courses London UK Resolved · Urgent Priority · Version 2003
Printing in VBA
by - delegate Nick [3 posts] (2008 Apr 28 Mon, 15:20) Reply
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
by - delegate Nick [3 posts] (2008 May 9 Fri, 13:06) Reply
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
|