PDA

View Full Version : Sleeper: Error in built-in dialog xlDialogPrinterSetup



ptlarson
03-10-2005, 04:23 PM
I use Application.Dialogs(xlDialogPrinterSetup).Show for selecting a printer on a custom print userform in Excel. It works great for selecting the printer, but the "Setup..." button on the dialog does not access the right printer until after you hit OK, then access the dialog again, and hit "Setup..." a second time.

Say you have two printers, P1, P2, and P1 is the default printer. You press the "Select Printer" button which calls Application.Dialogs(xlDialogPrinterSetup).Show. Then select P2, and press "Setup..." (to change printer properties). This gives properties for P1, rather than P2, even though P2 is highlighted. Apparently the dialog doesn't pass along the highlighted printer to the properties query, but rather passes the active printer.

Is there any way around this so you don't have to access the dialog twice in order to change printer properties? Here is the code I use...


Private Sub CommandButton4_Click()
'print setup (select printer)
Application.Dialogs(xlDialogPrinterSetup).Show
End Sub

TonyJollans
03-11-2005, 02:47 AM
Hi ptlarson,

Welcome to VBAX!

I'd be very interested to know if there's a fix for this, but I suspect not. I've done a fair bit with built-in Dialogs (more in Word than Excel) and they are extremely difficult to work with, poorly documented, and not at all consistent. I have found that trial and error on an individual dialog basis is the only way to go. What you see is what you get! And what you describe does seem to be the case here.