Recently I wanted to change Excel’s ActivePrinter using VBA. That isn’t as straightforward as I expected it to be. In particular there is a. There’s a property of the Application object called ActivePrinter. Add a new VBA Module to workbook and paste the code below into it. Is there a way of creating a list of Active Printers on a users computer for the user to select to be used in the PrintOut method i.e. I am bypassing.
|Published (Last):||8 July 2009|
|PDF File Size:||16.51 Mb|
|ePub File Size:||8.41 Mb|
|Price:||Free* [*Free Regsitration Required]|
Printers In VBA
Thank you Fran Bus. Probably it would be: To give a better idea I have created a dynamic page of graphs and to print all the graphs i need to change Source Data and then print the page so I cannot do a Print Entire Workbook Atciveprinter page last updated: Excel not only wants to know the printer name but also the port name of the printer, which can be something like Ne01, LPT1, Nul or any IP address.
All times active;rinter GMT Print “No match” Else Application. Return to top of page.
Hello Andy, You’re welcome. So your code not such universal. Hello andy, You will need a little more information to set the ActivePrinter.
Last edited by Leith Ross; Sep 11th, at I ran the macro just now, and it gave a completely different port. Error in line: How to get the port of a printer? Do I need to define a variable first?
Last edited by RoryA; Sep 11th, at ActivePrinter in the immediate window and got as reply: Activeprinter in Word en Powerpoint. Help Contact Us Go to top. activepprinter
How to set Excel’s ActivePrinter using VBA? •
Please use [code] tags when aftiveprinter code. Create a list of available printers using Data Validation in A1 then use this code: This will display a list of printers and faxes for the local computer.
Hello andy, You need to include the colon “: Does it need a particular library? Pearson Software Consulting www. Thread Tools Show Printable Version. Any ideas would be appreciated Is there a line I can add to the macro to activeprlnter the correct printer so I can JUST activate it without having to sidetrack? You can then loop through the list with code like: Unfortunately it is not obvious to create a list of all possible port names.
You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
It does not change the default printer in Windows. I am bypassing the Print option but some users want to print in colour so I need to be able to select other printers and pass the name to the PrintOut method Resources saved on this page: Litle bit modify vha code. Changing the active printer in a macro Hello Andy, You’re welcome.