0

Hope someone can help with the above error.

I have the following code that worked fine with windows xp and a Kodak scanmate 1120

 Private Sub BtnScan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnScan.Click
    Dim img As WIA.ImageFile = Nothing
    Dim wiaDialog As WIA.CommonDialog = New WIA.CommonDialog
    Dim wiaScanner As WIA.Device
    Dim root As String = "c:\myimages"
    Dim IFileName As String = TxtInvoiceNo.Text
    Dim WiaCommonDialog As New WIA.CommonDialog

    If TxtInvoiceNo.Text = "" Then
        'FrmPicDisplay.Show()
        MsgBox("Please enter a valid Invoice No." & vbNewLine _
           & "Then press scan button to continue.")
        TxtInvoiceNo.Select()

    ElseIf My.Computer.FileSystem.FileExists(root & IFileName & ".bmp") Then
        MsgBox("This filename already exists," & vbNewLine _
            & "Please enter a different filename")
        TxtInvoiceNo.Text = ""
    Else
        Ino = TxtInvoiceNo.Text
        wiaScanner = wiaDialog.ShowSelectDevice
        With wiaScanner.Items(1)
            .Properties("6146").Value = 4 '4 is Black-white,gray is 2, color 1 (Color Intent)
            .Properties("6147").Value = 200 'dots per inch/horizontal
            .Properties("6148").Value = 200 'dots per inch/vertical
            .Transfer(wiaFormatTIFF) '("{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}") 'BMP format - This prompts the scan
        End With


        img = wiaScanner
        Dim Item As WIA.Item = TryCast(wiaScanner.Items(1), WIA.Item)
        Dim imageBytes As [Byte]() = DirectCast(img.FileData.BinaryData, Byte())
        Dim ms As New MemoryStream(imageBytes)
        Dim image_1 As Image = Image.FromStream(ms)


        img.SaveFile("c:\myimages" & TxtInvoiceNo.Text & ".bmp")

I had to change the pc to windows seven and now the program doesn't work and gives me the above error at the line

 img = wiaScanner

From what I have found by searching it sounds like a com exception but I don't really understand where to start looking so any help would be very much appreciated.

Thanks Gareth

Gazza
  • 95
  • 2
  • 9
  • You are trying to convert a device to a file. That makes no sense, an E_NOINTERFACE error is expected. The Transfer() method returns an file, you are not using it. – Hans Passant Jan 13 '14 at 14:28
  • Thanks Hans for pointing that out (and for not calling me stupid for not noticing it in the first place) – Gazza Jan 18 '14 at 09:12

0 Answers0