discountspaster.blogg.se

How to change default printer in microsoft excel
How to change default printer in microsoft excel






  1. #How to change default printer in microsoft excel how to#
  2. #How to change default printer in microsoft excel full#

#How to change default printer in microsoft excel full#

' This function returns the full name of the first printerdevice that matches Printer.

how to change default printer in microsoft excel

Public Function GetPrinterFullName(Printer As String) As String If sPrinter = vbNullString Then ' no matchĭebug.Print "Temp printer: ", Application.ActivePrinterĪpplication.ActivePrinter = sDefaultPrinter SPrinter = GetPrinterFullName("PDFCreator") SDefaultPrinter = Application.ActivePrinter ' store default printer Running the test procedure below resulted on my Dutch Windows machine in:ĭefault printer: Brother HL-4150CDN op Ne06:ĭebug.Print "Default printer: ", Application.ActivePrinter Remaining question: is it possible that a windows installation has no printer installed? I don’t know, but in that case the code below will probably fail. Just take the current ActivePrinter value, split it and the last but one item in the array is your locale “on”. I almost decided to hard code the string for the above mentioned languages when I realized that the solution is already there. I expected there would be a Locale constant for this but I couldn’t find it. So they won’t work with a German (auf), Spanish (en), French (sur) or Dutch Windows (op). Unfortunately both solutions use a hard coded English “on” to create the full printer name, as in “PDFCreator on Ne01:”. On Experts Exchange Rory Archibald gave a solution based on WMI, which I use below. On Chip Pearson’s site I found Listing Printers In VBA. Use API functions to retrieve all your installed printers and there port names from the registry.Would be fine, but I don’t want to bother the user with this. Use Application.Dialogs(xlDialogPrinterSetup) and ask the user to select the printer.Unfortunately it is not obvious to create a list of all possible port names. In a loop set the ActivePrinter to every possible port name until it doesn’t fail.And do that on all machines of all users? No way!

how to change default printer in microsoft excel how to change default printer in microsoft excel

  • Configure the printer ports in Windows.
  • #How to change default printer in microsoft excel how to#

    How to get the port of a printer?Ī google on “excel activeprinter port” gave solutions like: I typed ?Application.ActivePrinter in the immediate window and got as reply:Įxcel 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. Unfortunately VBA gave me a runtime error 1004. I wanted to use VBA to set the ActivePrinter temporarily to my PDFCreator printer. In particular there is a localization issue.Īt startup Excel will set Application.ActivePrinter to your default printer, in my case usually a Laserjet. That isn’t as straightforward as I expected it to be. Recently I wanted to change Excel’s ActivePrinter using VBA.








    How to change default printer in microsoft excel