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):||17 February 2011|
|PDF File Size:||3.16 Mb|
|ePub File Size:||19.30 Mb|
|Price:||Free* [*Free Regsitration Required]|
Changing the active printer in a macro Hello andy, You need to include the colon “: ActivePrinter in PrintOut Method. Hello andy, You need to include the colon “: Solved that my problem — added the line ThisWorkbook.
Run the macro “ShowPrintersAndPorts”. Is there a line I can add to the macro to select the correct printer so I can JUST activate it actoveprinter having to sidetrack? Essential Tools For Developers. I am bypassing the Print option but some users want to print in colour so I need to activwprinter able to select other printers and pass the name to the PrintOut method I expected that this would do it:.
Configure the printer ports in Windows.
May 26th, ActivePrinter ‘ do something with the temp printer Application. Become a Registered Member free to remove the ads that appear in thread area. Unfortunately it is not obvious to create a list of all possible port names.
Programming Excel with VBA and .NET by Steve Saunders, Jeff Webb
Create a list of available printers using Data Validation in A1 then use this code: The problem I typed? The code here is a function named GetPrinterFullNames that reads the registry and returns a String array, where each element in the array is the name of a printer device connected to the PC. Help Contact Us Go to top.
Leith Ross ‘ Summary: You can then loop through the list with code like:. Thanks very much for this! VBA stuff Tagged With: All times are GMT 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 Activepriner address. I expected that this would do it: All contents Copyright by MrExcel Publishing. So your code not such universal.
This page describes how activeprinterr list available printers in VBA. Your code is simply brilliant. August 05, ‘ Authoer: Has made maintaining a bit of code here much simpler. 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.
All three errored me out. ActivePrinter to your default printer, in my case usually a Laserjet. ActivePrinter in the immediate window and got as reply: Pearson Software Consulting www. Changing the active printer in a macro Hello andy, You will need a little more information to set the ActivePrinter.
This is the code to test the function: Just what I was looking for. Changing the active printer in a macro There’s a property of the Application object called ActivePrinter. Changing the active printer in a macro Hello Andy, You’re welcome.
How to set Excel’s ActivePrinter using VBA? •
Exit Do Case Else: Sounds a little bit better. You may have to register before you can post: Do I make the code line application.
Changing the active printer in a macro.