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
Hey there, my name is Ajibola and I'm excited to help you out today!
To automate printing to PDF using Microsoft Print to PDF in Excel using VBA, you can use the following code.
Sub RUN_PRINT() ' Set the PDF printer as default printer Application.ActivePrinter = "Microsoft Print to PDF"
' Print the active sheet to PDF ActiveSheet.PrintOut
' Reset the default printer to the original printer Application.ActivePrinter = Application.DefaultPrinter End Sub
If you have any further questions or need additional assistance, please feel free to ask. I'm here to help!
If the reply was helpful, please don’t forget to upvote or accept it as an answer, Thank you
Kind regards
Hi,
I am not able to print it to PDF using your code. Cn you please share another code to print it to PDF only.
Please advice.