Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

printing vba

ResolvedVersion 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 courses

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
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Filtering Data in an Excel 2010 Worksheet

When you have an Excel Worksheet with masses of data, it's not going to be easy to sift through it. So, in order to view sections of data, you can use the filter tool. Select the cells you want to filter (no need to select the column headers), then click the Home tab on the Ribbon, click Sort and Filter (you will find this in the Editing Section) then click Filter.

You will now see arrows in the top row of all the columns. If you click on an arrow, it will give you some filtering options so you can sort your data into ''Smallest to Largest'' or ''Oldest to Newest'' and so on..

To turn off the filtering, go back to the Home tab and click the Filter button again.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.