how to set Printer Driver Properties in Excel Layer

58 Views Asked by At

Hello! First of all, I don't know English because I'm Korean So I'm sorry to upload questions using a translator.

When printing with "VBA", I want to know if there is a way to configure a printer driver properties

I try to print a label with the "Honeywell PM42" label printer using Excel, but I want to simplify the work every time the user needs to change the paper size.

My English is messed up. So maybe you can't understand the question. If you leave the answer, I will always give you feedback.

Printer Properties

Honeywell PM42 Properties

**I couldn't find a way, so I tried this.

However, when printing in "Excel Workbook", the changed properties in "OS Layer" were ignored.**

Sub SW_OpenPrintingPreferences(ByRef printerName As String)
    'Dim printerName As String
    Dim hwnd As LongPtr
    Dim result As LongPtr
    
    ' Replace "Your Printer Name" with the name of the printer whose Printing Preferences you want to open.
    'printerName = "Microsoft print to pdf"
    
    ' Set the hwnd to 0 to indicate that no parent window is available.
    hwnd = 0
    
    ' Open the Printing Preferences.
    ' Note: The "printui.dll" command is used to open the printer properties.
    ' You can use different command-line options for specific tasks, but "/p /n" will open the printer properties.
    result = ShellExecute(hwnd, "open", "rundll32.exe", "printui.dll,PrintUIEntry /e /n """ & printerName & """", vbNullString, vbNormalFocus)
    
    ' Check the result. If it's less than or equal to 32, an error occurred.
    If result <= 32 Then
        MsgBox "Error opening Printing Preferences!", vbExclamation
    End If
End Sub

So I tried the following two methods to solve the problem in "Excel Workbook", but as a result, the work was not simplified for the user and had to change the settings every time.

  1. Application.Dialogs(xlDialogPrint).Show

  2. Application.Dialogs(xlDialogPrinterSetup).Show

**I want to reduce the person's mistake by automating the print without touching the settings.

Can you help me?**

0

There are 0 best solutions below