Hello
Here is a VBA code to set the default printer to Microsoft Print to PDF:
CreateObject("WScript.Network"). SetDefaultPrinter "Microsoft Print to PDF"
Kind regards
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
how to write VBA Code for Ensuring when print is done, it is done automatically using Microsoft Print to PDF using VBA Code in the macro called as "RUN PRINT"
Please share the code
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Hello
Here is a VBA code to set the default printer to Microsoft Print to PDF:
CreateObject("WScript.Network"). SetDefaultPrinter "Microsoft Print to PDF"
Kind regards
Hello,
If you run this macro, it will change the default printer to Microsoft Print to PDF, regardless of the current default printer.
Kind Regards
Dear Sir,
You are right but That excel sheet is going to be used by everyone and i can not set default printer for everyone in control panel. User are 1000 in numbers but they will use same excel file and same macro. So it is easy to force it using VBA Code here?
How to set default printer using VBA code before sending print command ?
Hello,
You can use VBA code to set the default printer before sending a print command in Microsoft Office applications like Word, Excel, or Access. Here's how you can do it:
Sub SetDefaultPrinterAndPrint()
Dim defaultPrinter As String
' Store the current default printer
defaultPrinter = Application.ActivePrinter
' Set the new default printer
Application.ActivePrinter = "Printer Name Here"
' Your printing code here
' For example:
ActiveSheet.PrintOut
' Restore the original default printer
Application.ActivePrinter = defaultPrinter
End Sub
Replace "Printer Name Here" with the name of the printer you want to set as the default.
Kind Regards
Hi,
your code is Ok but i want to set default printer always to Microsoft Print to PDF here.
How to do it ?
Regards,