Excel - creating a print macro

I recorded a macro to print an excel sheet at the click of a button. But I want to specify a printer, which it automatically prints, and does not give the user a choice. I also print in PDF, so that I can choose where I print?

This is what I have so far:

Sub Publish()
    '
    ' Publish Macro
    ' Macro recorded 07/09/2010
    '
    ' Keyboard Shortcut: Ctrl+Shift+S
    '
        ActiveWindow.SelectedSheets.PrintOut Copies:=1
    End Sub
+3
source share
1 answer

Try to add

Application.ActivePrinter = "Printer Name"

in the line above the PrintOut command. This link gives more information about ActivePrinter, although it is more focused on MS Word.

+3
source

Source: https://habr.com/ru/post/1753933/


All Articles