views:

291

answers:

1

But I have several printers installed. I think the code is pretty standard...

    Dim printDocument As New System.Drawing.Printing.PrintDocument
    Dim pageSetupDialog As New System.Windows.Forms.PageSetupDialog
    pageSetupDialog.Document = printDocument
    pageSetupDialog.ShowDialog()

Did I miss something? I can even enumerate through my printers in code (I've got five of them). One is set as the system default. What's going on?

+1  A: 

Did you try assigning PageSettings and PrinterSettings on your dialog before calling ShowDialog() ?

pageSetupDialog .PageSettings = _
    New System.Drawing.Printing.PageSettings

pageSetupDialog .PrinterSettings = _
    New System.Drawing.Printing.PrinterSettings

Source.

EDIT: This page about the exception says:

Make sure a default printer has been installed.

Do you have one installed?

JeffH
Thanks for the post; but that didn't seem to make a difference.Oddly enough, if I inspect the .PageSettings.PrinterSettings I can see my installed printers. Weird.
Rob P.
See my edit about possibly needing a default printer installed.
JeffH