Scanning documents

DeonO

Novice Programmer
Local time
Today, 08:51
Joined
Sep 15, 2011
Messages
31
Hi,
I have a module that scans documents into a database. I am using a local (USB Connected) rather old scanner from Fujitsu. The code works perfectly and all files are scanned and stored as it should.
The customer has now requested that they want to scan across the network, not from a local scanner. The printer/Scanner is a Minolta printer/scanner. I have never done this before, so I am stuck.

My partial code below (with compliments from http://kbase.icbconsulting.com/vba/scan-documents-into-an-access-database). I have changed some code to comply to my conditions.

Code:
blnContScan = True
intPages = 0
strTempFolder = "C:\Temp"
ScanStarted = "N"
Do While blnContScan = True
    DPI = 200
    PP = 1 'No of pages
    Set Scanner = Dialog1.ShowSelectDevice(WIA.WiaDeviceType.ScannerDeviceType, False, False)
    With Scanner.Items(1)
        .Properties("6146").Value = 1 'Colour intent (1 for color, 2 for grayscale, 4 for b & w)
        .Properties("6147").Value = DPI 'DPI horizontal
        .Properties("6148").Value = DPI 'DPI vertical
        .Properties("6149").Value = 0 'x point to start scan
        .Properties("6150").Value = 0 'y point to start scan
        .Properties("6151").Value = 8.27 * DPI 'Horizontal extent
        .Properties("6152").Value = 11.69 * DPI     'Vertical extent for letter
    End With
    Set img = Dialog1.ShowTransfer(Scanner.Items(1), wiaFormatJPEG, True)
    'Set img = Scanner.Items(1).Transfer(WIA.FormatID.wiaFormatJPEG)
    intPages = intPages + 1
    strFileJPG = strTempFolder & "\" & strFileName & Trim(Str(intPages)) & ".jpg"
    If FSO.FileExists(strFileJPG) Then
        FSO.DeleteFile (strFileJPG)
    End If
    Set FSO = Nothing
    img.SaveFile (strFileJPG)
    DoCmd.SetWarnings False
    DoCmd.RunSQL "insert into scantemp (picture) values ('" & strFileJPG & "')"
    DoCmd.SetWarnings True
    Set Scanner = Nothing
    Set img = Nothing
    strFileJPG = ""
    ScanStarted = "Y"
    'Prompt user if there are additional pages to scan
    'ContScan = MsgBox("Scan another page?", vbQuestion + vbYesNo, "Continue...?")
    'If ContScan = vbNo Then
    '    blnContScan = False
    'End If
Loop

The issue is that when the code runs, it does not pick up the network printer / scanner and gives an error message that the WIA device is not found.
Any suggestions?

Thanks
Deon
 
is the printer installed in your printers?
is the WIA in the vbe references? menu: tools, references, checkmark WIA object
 
Hi,
Yes, the printer is installed and the WIA is in the references:
Capture.JPG
 
Hi,
Is it possible to code the following line somewhere where it will be run only once and not everytime as currently in the loop.

"Set img = Dialog1.ShowTransfer(Scanner.Items(1), wiaFormatJPEG, True)"

The problem is that as the code in the loop is run every time that the above code executes, the dialogue pops up because there is more than one scanner listed. If I remove all but 1 scanner, then the dialogue does not pop up.
If I place this line before the loop, I get an error message ""Object variable or With block variable not set" as soon as the loop is in the second loop.

Thanks
 

Users who are viewing this thread

Back
Top Bottom