WIA scanning issues in VBA changing the default paper size (1 Viewer)

fearmichaele

Registered User.
Local time
Today, 11:09
Joined
Jan 14, 2014
Messages
34
I am working on a project which will eliminate several steps of the user to scan a document using a 3rd party software, manually naming the document using a predetermined naming convention, and placing it in a predermined folder.

i have successfully used a VBA scanner code from an earlier post that allows the user to scan, name and place in the folder without using 3rd party software. My issue i can not figure out is how to change the paper size. The scanner i am using is a fujitsu WIA compatable scanner. it is defaulting to 8.5 X 14 paper. i need it to default 8.5 X 11 paper. when i use the WIA interface on windows it defaults to LETTER but when i use it in VBA I get LEGAL size.

I have emailed the scanner company tech support for help but they have yet to respond.

here is my current code

Code:
Private Sub Command77_Click()
'returned rx, scan and complete

Dim authnum As String

     verifymsg = "You are scanning a prescription for  " me.persons name & " Is this correct?"
     response = MsgBox(verifymsg, vbYesNo, "Please verify Name")
     If response = vbNo Then
     GoTo skipscan
     Else
         msg = "Place document for " &  me.persons name & " in scanner and press OK to proceed"
        MsgBox (msg)
         authnum = Mid$([auth number], 2, 7)
         rxname =  me.persons name & authnum & ".tif"
         
    End If
  On Error GoTo Errhand
  
  
Const wiaFormatBMP = "{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}"
Const wiaFormatPNG = "{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}"
Const wiaFormatGIF = "{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}"
Const wiaFormatJPEG = "{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}"
Const wiaFormatTIFF = "{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}"
Const wia_ips_page_width = 8500
Const wia_ips_page_height = 11000

  Dim ComDialog As WIA.CommonDialog
  Dim DevMgr As WIA.DeviceManager
  Dim DevInfo As WIA.DeviceInfo
  Dim dev As WIA.Device
  Dim img As WIA.ImageFile
  Dim i As Integer
  Dim wiaScanner As WIA.Device

  Set ComDialog = New WIA.CommonDialog
  Set wiaScanner = ComDialog.ShowSelectDevice(WiaDeviceType.UnspecifiedDeviceType, False, False)
  
  Set DevMgr = New WIA.DeviceManager

  For i = 1 To DevMgr.DeviceInfos().Count
    If DevMgr.DeviceInfos(i).DeviceID = wiaScanner.DeviceID Then
      Set DevInfo = DevMgr.DeviceInfos(i)
    End If
  Next i

  Set dev = DevInfo.Connect

scanitem:

  Set img = dev.Items(1).Transfer(wiaFormatTIFF)

  img.SaveFile "\\filepath name where i store the documents" & rxname

  Set img = Nothing
  Set dev = Nothing
  Set DevInfo = Nothing
  Set DevMgr = Nothing
  Set ComDialog = Nothing
GoTo finish

Errhand:
msg2 = "No Rx detected in scanner.  Please place Rx in scanner to proceed"
MsgBox (msg2)
GoTo scanitem

skipscan:
GoTo finish

Finish:
end sub
[CODE]

this works but only scans 8.5 X 14 in paper and outputs 8.5 X 14 .  I dont want the user to have to choose the paper size each time because that is what they are doing using the 3rd party software and I need to increase their effiecency by providing them a mechanism to use the database form they are constantly in and scan for them.

i have search all the other forums till my eyes are crossed (literally)
i have tried adding this code to my routine but get run time error 91.
[CODE]
 With wiaScanner.Items(1)
   .Properties("6151").Value = 2550
    .Properties("6152").Value = 3300
End With

Is there anyone out there who has solved a problem like this?
 

fearmichaele

Registered User.
Local time
Today, 11:09
Joined
Jan 14, 2014
Messages
34
UPDATE:

I finally figured out how to scan a 8.5 X 11 document. i added the following code to my module
Code:
Set wiaScanner = ComDialog.ShowSelectDevice(WiaDeviceType.ScannerDeviceType, False, False)
 wiaScanner.Properties("3088").Value = 1 'Automatic Document Feeder
        wiaScanner.Items(1).Properties("6146").Value = 4 'Colour intent
        wiaScanner.Items(1).Properties("6147").Value = 300 'DPI horizontal
        wiaScanner.Items(1).Properties("6148").Value = 300 'DPI vertical
        wiaScanner.Items(1).Properties("6149").Value = 0 'x point to start scan
        wiaScanner.Items(1).Properties("6150").Value = 0 'y point to start scan
        wiaScanner.Items(1).Properties("6151").Value = 2550  'Horizontal extent
        wiaScanner.Items(1).Properties("6152").Value = 3300    'Vertical extent for A4
        wiaScanner.Items(1).Properties("6154").Value = 80 'brightness
then i changed the scan item from
Code:
Set img = dev.Items(1).Transfer(wiaFormatTIFF)
to
Code:
Set img = wiaScanner.Items(1).Transfer(wiaFormatTIFF)
now i am scanning a single page to the correct size to the folder.

Now i am stumped on how to scan multiple pages. Anyone have any way to do this? do i need to place all this in a loop?

any insite will greatly be appreciated.
 

fearmichaele

Registered User.
Local time
Today, 11:09
Joined
Jan 14, 2014
Messages
34
i have the scanning part working. it scans multiple sheets from the ADF but scans each sheet in a separate tif file. now to research how to combine the tiff files into one file.
 

Users who are viewing this thread

Top Bottom