Written by Allen Wyatt (last updated August 19, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021
On Bob's system, Excel refuses to print to any printer other than the one set as the default for the system. This only happens in Excel, not in Word or any other installed application. So in order to print he has to temporarily change the default printer to the one he wants, print, and then remember to set the printer back afterwards. Bob is wondering why he can't choose other printers.
There could be a number of different causes for this problem. One subscriber reported that they had the same problem but that it only cropped up after migrating their office to Windows 7 64-bit and using Windows PrintServer. In their case, they discovered that their was a hidden attribute on the printer queues which caused the problem and they could only get it taken care of by talking with Microsoft support.
Others reported the problem occurring when particular add-ins were installed on the system. (One in particular, Microsoft Office Labs Search Command, was mentioned a few times.) Disabling the add-in solved the problem.
There is a mention of the problem and various fixes here (make sure you click on the Replies drop-down to see the different fixes):
https://answers.microsoft.com/en-us/msoffice/forum/all/excel-2010-only-prints-to-the-default-printer/5b6beddd-f85d-4fda-ab2b-56c750f2028c
You'll want to ensure that this is entered in your browser as a single URL; it is quite long.
If none of the suggested solutions work in your situation, you can try printing via macros. Why? Because you can easily modify the designated default printer in the macro and then change it back. It's all done through the use of the ActivePrinter property. You can determine the name of the current default printer and assign it to a variable, change the printer, then do your printing, and finally change the printer back:
Dim sDefault As String sDefault = Application.ActivePrinter 'save current default printer Application.ActivePrinter = "XYZ SuperPrinter" ' do your printing Application.ActivePrinter = sDefault 'restore default
The only thing you need to do is to make sure that you replace "XYZ SuperPrinter" with the actual name of the printer you want to use. You can find out the name of the printer by making it the default (in Windows) and then, within the VBE Immediate window, printing the name of the printer:
? Application.ActivePrinter
Mark down the name, paying attention to spacing and capitalization, and that is the name you can use in the printing macro.
If this still doesn't work for your needs, then you need to be aware that Microsoft has changed, in the most recent versions of Excel, how the .ActivePrinter property is correctly set. See the following ExcelTip for additional information:
https://tips.net/T13896
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12497) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021.
Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!
In a large worksheet, you may want to display and print just a portion of the available data. Displaying the desired ...
Discover MoreExcel is rather weak on giving you control over how page numbers appear on a printout. This is never more apparent than ...
Discover MoreExcel doesn't allow for as robust of headers and footers as Word does. Even so, there are some things you can do to ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2023-08-29 16:10:44
J. Woolley
The Tip says "you can easily modify the designated default printer" and provides a macro for that purpose; however, the Tip's macro changes the active printer, not the default printer. Excel's active printer can easily be changed using its Print dialog (Ctrl+P) without a macro.
The following macro will create and run a VBScript to toggle the default printer:
Sub ToggleDefaultPrinter()
Const sNewDef = "Microsoft Print to PDF", sNewOnNe = "Ne03:"
Const sMyName = "ToggleDefaultPrinter"
Const Q = """", QQ = Q & Q, NL = vbNewLine, BL = NL & NL
Dim oShell As Object
Dim sLocale As String, sDefPrn As String, sPrnMgr As String
Dim sSetDef As String, sCmdOne As String, sCmdTwo As String
Dim sMsg As String, sScript As String, sPath As String
Set oShell = CreateObject("WScript.Shell")
sLocale = oShell.RegRead("HKCU\Control Panel\International\LocaleName")
sDefPrn = oShell.RegRead("HKCU\Software\Microsoft\Windows NT\" _
& "CurrentVersion\Windows\Device")
sDefPrn = Trim(Split(sDefPrn, ",")(0))
sPrnMgr = "%windir%\System32\Printing_Admin_Scripts\" & sLocale _
& "\prnmngr.vbs"
sSetDef = "cscript.exe " & sPrnMgr & " -t -p "
sCmdOne = "cmd.exe /c " & sSetDef & QQ & sNewDef & QQ
sCmdTwo = "cmd.exe /c " & sSetDef & QQ & sDefPrn & QQ
'be careful with the following quotation marks
sMsg = """The new default printer is"" & NL & """ & sNewDef _
& """ & BL & ""Click OK to restore the old default"" & NL & """ _
& sDefPrn & """"
'avoid changes to the following VBScript
sScript = "NL = vbNewLine: BL = NL & NL" & NL _
& "Set oShell = CreateObject(""WScript.Shell"")" & NL _
& "oShell.Run " & Q & sCmdOne & Q & ", 0, True" & NL _
& "nButton = oShell.Popup(" & sMsg & ", , " & Q & sMyName & Q _
& ", (1+64+4096))" & NL _
& "If nButton = 1 Then oShell.Run " & Q & sCmdTwo & Q & ", 0, True"
sPath = Environ("Temp") & "\~" & sMyName & ".vbs"
Open sPath For Output Lock Write As #1: Print #1, sScript: Close #1
oShell.Run "WScript.exe " & Q & sPath & Q, 0, False
'do not Kill sPath
Set oShell = Nothing
Application.ActivePrinter = sNewDef & " on " & sNewOnNe
End Sub
Update Const sNewDef and sNewOnNe with the name and "Ne-port" for your new default printer. If you have a Print Server, you might need to modify the value of sSetDef in the macro; see https://ss64.com/nt/prnmngr.html
When you run ToggleDefaultPrinter, the old default printer will be changed to sNewDef followed by a Popup similar to the screenshot (see Figure 1 below) and Excel's active printer will be changed accordingly. The Popup will persist until it is dismissed; in the meantime you can print to the new active (default) printer with Excel in the usual way. Finally, click the Popup's OK button to restore the old default printer, or Cancel to retain the new one; Excel's active printer will not change, however.
The Tip references https://tips.net/T13896 for discussion about a printer's "Ne-port" and how to set Application.ActivePrinter. See my comment there regarding the ListPrinters function in My Excel Toolbox, which also includes the following function to return the value of Application.ActivePrinter:
=NameOf("printer")
The NameOf function is described in my comment at https://excelribbon.tips.net/T013432
See https://sites.google.com/view/MyExcelToolbox
Figure 1.
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments