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):||22 December 2004|
|PDF File Size:||19.88 Mb|
|ePub File Size:||1.31 Mb|
|Price:||Free* [*Free Regsitration Required]|
Once you find the printer name and it’s port you can change it using the method WBD posted. The time now is Exit Do Active;rinter Else: Do I make the code line application.
Just what I was looking for. Vvba, I need to manually select the printer and close out of the ‘print’ screen before I activate it. Any ideas would be appreciated To start viewing messages, select the forum that you want to visit from the selection below.
Recent comments cbd clinic products on Excel and XML: Add a new VBA Module to workbook and paste the code below into it.
You can download a working XLS workbook that displays everything discussed on this page. Changing the active printer in a macro. You could just set that if you know the name of the activperinter At startup Excel will set Application.
You can then loop through the list with code like:. It does not change the default printer in Windows. Replacing USB with that solved the issue. I have 32 bit Windows API code that gets the device names and works well locally, but needs additional work for network printers.
Share it with others Like this thread? Solved that my problem — added the line ThisWorkbook. VBA stuff Tagged With: The code on this page gets its list of printers from the system registry, specifically the key. Changing the active printer in a macro Leith Ross – When you said I needed the printer name and port, I accessed the devices and printers instead of running the macro, and when I saw on USB, it stood to reason that that was the port.
Glad you have everything working now. You can then loop through the list with code like: 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.
May 26th, Run the macro “ShowPrintersAndPorts”. All three errored me out. Note that setting the ActivePrinter ‘ changes the default printer for Excel but does not change ‘ the Windows default printer.
Probably it would be: So your code not such universal. This will get the list of availble printers. Activeprinter in Word en Powerpoint.
All times are GMT Hello andy, You will need a little more information to set the ActivePrinter. How to get the port of a printer? Thank you Fran Bus.
The value can ‘ be used to assign a printer to the ActivePrinter activeprinteer of ‘ the Application object. And do that on all machines of all users? Is there a line I can add to the macro to select the correct printer so I can JUST activate it without having to sidetrack?
All contents Copyright by MrExcel Publishing. Use API functions to retrieve all your installed printers and there port names from the registry.
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 Activeprinher