I’m trying to scan multiple A4 pages to jpegs using WIA and ImageProcess from the auto-document feeder on my scanner.
Individual scans work fine as does the first scan from the document feeder. These are scanned and saved fine. The process fails during the second document from the feeder with the message: Error No -2147024809: The parameter is incorrect. At this point the scanner just stops with the page half fed through.
Can anyone see where I am going wrong with the following code? I have tried a few variations but none of them work for a second document.
Code:Private Sub Scan_Click() On Error GoTo Err_Handler Dim info As String info = InputBox("Please enter scan description.", "Scan information.") If IsValidFileName(info) = False Then MsgBox "The following characters cannot be used in the description:" & vbCrLf & vbCrLf & " \ / : * ? < > | " & Chr(34) Exit Sub End If MsgBox "Please load the document you wish to scan and click ok." Dim wiaImg As New WIA.ImageFile Dim wiaDialog As New WIA.CommonDialog Dim wiaScanner As WIA.Device Dim IP As ImageProcess Set IP = CreateObject("WIA.ImageProcess") IP.Filters.Add (IP.FilterInfos("Convert").FilterID) IP.Filters(1).Properties("FormatID").Value = WIA.FormatID.wiaFormatJPEG IP.Filters(1).Properties("Quality").Value = 25 Set wiaScanner = wiaDialog.ShowSelectDevice 'MsgBox wiaScanner.Properties.item("3087").Value Dim counter As Integer counter = 1 ADFStatus = True While ADFStatus With wiaScanner.Items(1) If ScanColour = True Then .Properties("6146").Value = 1 '4 is Black-white,gray is 2, color 1 (Color Intent) Else .Properties("6146").Value = 2 '4 is Black-white,gray is 2, color 1 (Color Intent) End If .Properties("6147").Value = 200 'dots per inch/horizontal was set at 100 .Properties("6148").Value = 200 'dots per inch/vertical was set ao 100 .Properties("6149").Value = 0 'x point where to start scan .Properties("6150").Value = 0 'y-point where to start scan 'Following is A4 paper size. _ '(Not 100% accurate because real A4 Ht errors) .Properties("6151").Value = 1660 'horizontal exent DPI x inches wide .Properties("6152").Value = 2334 'vertical extent DPI x inches tall Set wiaImg = .Transfer(wiaFormatJPEG) 'Change file type in save to match format End With Set wiaImg = IP.Apply(wiaImg) If counter = 1 Then wiaImg.SaveFile (gdrive & "Scan\" & Format(Date, "yyyy_mm_dd") & "_" & Format(Time, "hh_mm_ss") & "_" & info & ".jpg") Else wiaImg.SaveFile (gdrive & "Scan\" & Format(Date, "yyyy_mm_dd") & "_" & Format(Time, "hh_mm_ss") & "_" & info & "_" & counter & ".jpg") End If ADFStatus = wiaScanner.Properties.item("3087").Value counter = counter + 1 Set wiaImg = Nothing Wend Set wiaScanner = Nothing Exit_Sub: Exit Sub Err_Handler: strMsg = "Error No " & Err.number & ": " & Err.Description MsgBox strMsg, vbExclamation, "Scan error." Resume Exit_Sub End Sub