Is there a VBA way to open Print Properties Dialog?

daniels012

Well-known Member
Joined
Jan 13, 2005
Messages
5,219
I know I've seen where the print Dialog window can be opened.
Is there a way to open the Print PROPERTIES Dialog window?
:) :) :) :) :rolleyes:
Thank You,
Michael
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Well, the print dialog is:
Code:
Application.Dialogs(xlDialogPrint).Show

But I think that the print properties dialog is linked to the printer/print drivers rather than being an Excel dialog box. As such, I'm not sure off hand how to bring that up. It may have to be some sort of Windows system control and you'd probably need to specify the printer somehow as well......
 
Upvote 0
Lewiy,
thank you for your response.
After some search i found this:
Code:
Option Explicit

Private Declare Function PrinterProperties Lib "winspool.drv" _
  (ByVal hwnd As Long, ByVal hPrinter As Long) As Long

Private Declare Function OpenPrinter Lib "winspool.drv" _
  Alias "OpenPrinterA" (ByVal pPrinterName As String, _
  phPrinter As Long, pDefault As PRINTER_DEFAULTS) As Long

Private Declare Function ClosePrinter Lib "winspool.drv" _
  (ByVal hPrinter As Long) As Long
  
Private Type PRINTER_DEFAULTS
   pDatatype As Long ' String
   pDevMode As Long
   pDesiredAccess As Long
End Type

Private Const STANDARD_RIGHTS_REQUIRED = &HF0000
Private Const PRINTER_ACCESS_ADMINISTER = &H4
Private Const PRINTER_ACCESS_USE = &H8
Private Const PRINTER_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or _
   PRINTER_ACCESS_ADMINISTER Or PRINTER_ACCESS_USE)
   Public Function DisplayPrinterProperties(DeviceName As String) _
  As Boolean
         
'PURPOSE:  Displays the property sheet for the printer
'Specified by Device Name

'PARAMETER: DeviceName: DeviceName of Printer to
'Display Properties of

'EXAMPLE USAGE: DisplayPrinterProperties Printer.DeviceName

'NOTES: As Written, you must put this function into a form
'module. To put into a .bas or .cls module, add a parameter for
'the form or the form's hwnd.

On Error GoTo ErrorHandler
Dim lAns As Long, hPrinter As Long
Dim typPD As PRINTER_DEFAULTS

typPD.pDatatype = 0
typPD.pDesiredAccess = PRINTER_ALL_ACCESS
typPD.pDevMode = 0
'DeviceName = Application.ActivePrinter
lAns = OpenPrinter(Printer.DeviceName, hPrinter, typPD)
If lAns <> 0 Then
    lAns = PrinterProperties(Me.hwnd, hPrinter)
    DisplayPrinterProperties = lAns <> 0
End If

ErrorHandler:
If hPrinter <> 0 Then ClosePrinter hPrinter
    
End Function

Only I have no idea how to make this work. I copied it into a module and now I don't know how to get it to run.

Any ideas? :confused: :confused:
Michael
 
Upvote 0
This is a Custom Function so you would need to type:
Code:
=DisplayPrinterProperties(DeviceName)
into a cell. Where DeviceName is the name of your printer. This could probably be converted quite easily into a Macro but I'm afraid it's a little beyond me what it's actually doing.
 
Upvote 0
Why in the world would you type in a function, to give you a Dialog box?
And is that even possible?

If you don't know, I really don't know????

Michael
 
Upvote 0
I found this which looks simpler:
Code:
Sub ShowPrinterProperties()    
Call Shell("rundll32 printui.dll,PrintUIEntry /p /n yourprinter")
End Sub
They have this also:
The part after \n can be defined in two ways:
1) Use the exact printername as it appears in your printer menu (case sensitive)
e.g. /n"HP Laserjet IIIP"
2) The UNC name of a shared printer. E.g. /n\\SERVER\SHAREDPRINTER

I still can't seem to get it correct??
Ideas?
Michael
 
Upvote 0
Hmmm, that seems to be trying to do what you need but I can't seem to get my printer name correct in the code although it looks exactly like the example........

I think you may have more luck with this one but it's all down to how you define the printer.
 
Upvote 0
I can't seem to get my printer name correct in the code
exactly the issue I am having.
It won't recognize my printer that I enter??

Not to good with this coding stuff!! Not sure what else to try? :confused: :confused:
Michael
 
Upvote 0
I have even tried this:
Code:
Sub ShowPrinterProperties()
    ActPrn = Application.ActivePrinter
    Call Shell("rundll32 printui.dll,PrintUIEntry /p /n ActPrn")
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,338
Messages
6,124,343
Members
449,155
Latest member
ravioli44

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top