Saving duplex wia scan

wackywoo105

Registered User.
Local time
Yesterday, 23:00
Joined
Mar 14, 2014
Messages
203
I use the following code to scan. I have manged to get it scanning from ADF correctly single sided. I also want to duplex scan. When I change document handling properties to duplex the scanner runs and clearly performs duplex scanning. The problem is nothing is saved.

What do I need to modify to make it save a duplex scan?

I've read a bit about calling the image transfer twice with duplex scanning. All the examples I've found are for C# coding though so I don't know the VBA equivalent.

I've even tried a couple of command line scanners NAPS2 and CLScan but sadly they don't work fully.


Code:
Function ScanDocNow(info As String, Counter As Integer, sizeh As Integer, sizev As Integer, ADF As Boolean, Duplex As Boolean, Rotate As Boolean)
Dim wiaImg As New WIA.ImageFile
Dim wiaDialog As New WIA.CommonDialog
Dim wiaScanner As WIA.Device
 
If ADF = True Then
    If Duplex = True Then
        wiaScanner.Properties.item("3088").Value = 5 ‘ duplex
    Else
        wiaScanner.Properties.item("3088").Value = 1 ‘ one sided
    End If
End If
 
With wiaScanner.Items(1)
    .Properties("6146").Value = 1 '4 is Black-white,gray is 2, color 1 (Color Intent)
    .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
    .Properties("6152").Value = sizev 'vertical extent DPI x inches tall was 2334
    .Properties("6151").Value = sizeh 'horizontal exent DPI x inches wide was 1660
     Set wiaImg = .Transfer(wiaFormatJPEG) 'Change file type in save to match format
End With
 
Dim IP As ImageProcess
 
Set IP = CreateObject("WIA.ImageProcess")
IP.Filters.Add IP.FilterInfos("RotateFlip").FilterID
IP.Filters(1).Properties("RotationAngle") = 270
Set wiaImg = IP.Apply(wiaImg)
Set IP = Nothing
 
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 wiaImg = IP.Apply(wiaImg)
 
If Counter = 1 Then
    wiaImg.SaveFile (gdrive & "Scan and Bin\" & Format(Date, "yyyy_mm_dd") & "_" & Format(Time, "hh_mm_ss") & "_" & info & ".jpg")
Else
    wiaImg.SaveFile (gdrive & "Scan and Bin\" & Format(Date, "yyyy_mm_dd") & "_" & Format(Time, "hh_mm_ss") & "_" & info & "_" & Counter & ".jpg")
End If
 
Set wiaImg = Nothing
Set wiaScanner = Nothing
 
End Function
 
a search turned up this ( I stopped looking at this point) which the OP claims works but is slow. Maybe it will point you in the right direction at least.
 
Thanks. I remember seeing that come up in a few searches but didn't realise it may help. I have tried it and modified my own code to copy it. Sadly it still doesn't save anything when using duplex. From other reading I think it may have something to do with the pages property, but I'm not sure why or how to fix it.
 

Users who are viewing this thread

Back
Top Bottom