Share via

VBA to View Printers List in Word

Anonymous
2021-07-18T19:37:20+00:00

Could you please support me with this VBA code?

The code shows a window to select a printer in Word and print in prn file.

However, I need the following to make it work properly:

1.- A button in the windows to allow me to set up the printer I select.

2.- A "OK" button

3.- Make the "Cancel" button to stop the macro because when I press the button cancel still print the file.

'##################################

Sub PrinterSelectionInWord()

Dim bChoice As Boolean

Dim cChoice As Boolean

Dim filename As String

bChoice = Application.Dialogs(wdDialogFilePrintSetup).Show

 ActiveDocument.PrintOut Range:=wdPrintCurrentPage, PrintToFile:=True, OutputFileName:="C:\Test\Test.prt"

If Not bChoice Then

VBA.MsgBox "User cancelled"

Else

    VBA.MsgBox ActivePrinter, vbOKOnly, "Active Printer"

End If

If Not cChoice Then

VBA.MsgBox "Setup"

End If

End Sub

'##################################

Thanks in advance

Maperalia

Microsoft 365 and Office | Word | For home | Windows

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.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Jay Freedman 207.5K Reputation points Volunteer Moderator
    2021-07-20T01:00:16+00:00

    This post is a duplicate of https://answers.microsoft.com/en-us/msoffice/forum/all/vba-to-select-printer-in-word/8a88b154-ffed-4107-8647-b67a79a7b91f . Please do not post duplicates; continue the discussion that you already started.

    1 person found this answer helpful.
    0 comments No comments