No printers installed error


  • Hello All...

    I'm using the following VB 2008 code which to me seems pretty straightforward.

        If myAppSettings.ReceiptPrinter.Length = 0 Then
          Dim pd As New PrintDialog()
          pd.PrinterSettings = New Printing.PrinterSettings()
          If pd.ShowDialog() = DialogResult.Cancel Then Return
          myAppSettings.ReceiptPrinter = pd.PrinterSettings.PrinterName
        End If

    The dialog displays with my printers listed and the default printer selected. When I click the Properties button, nothing happens. When I close the dialog, I get an ArgumentException "Handle 0 is not valid." Looking at the pd object, any property that references a printer setting displays "No Printers are Installed."

    I can enumerate through the printers using this code and they are all listed.

        For i As Integer = 0 To PrinterSettings.InstalledPrinters.Count - 1
          myPrinters += PrinterSettings.InstalledPrinters.Item(i) & vbCrLf

    And this code return an error "No Default Printer Specified."

        Dim ps As New Printing.PrinterSettings
        myPrinter = ps.PrinterName

    All of my printers are network printers.

    Does anyone have any idea why this is happening and how to correct it?

    Thanks everyone..

    Michael White

    Marion County, Oregon

    Thursday, August 09, 2012 10:52 PM


All replies