Solved

ADF Scanner In Access Using VBA and WIA

Posted on 2011-02-21
11
3,459 Views
Last Modified: 2012-05-11
I have searched the entire internet and not found a single example that shows VBA code for using a ADF scanner. I am using Miscrosoft Access 2007 and Windows 7. Does any one have a simple code for this using WIA? I can't find anywhere that shows how to specify that you are using a ADF scanner not a flatbed.

Thank you.
0
Comment
Question by:krystalj
11 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 34945397
Did you check the help file that comes with WIA SDK? I know there is an example in it, but I can't recall if it shows using ADF.
0
 
LVL 34

Expert Comment

by:Gary Patterson
ID: 34945568
0
 

Author Comment

by:krystalj
ID: 34945843
I tried the solution from Gary for Excel. I'm using Access and I can't seem to translate it. over Thanks.
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 84
ID: 34946219
The solution at the link by Gary is a standard VBA solution, and would work for Access or Excel. In that link, the "solution" seemed to be for that person to insure that the drivers installed on the machine were the correct ones for the Operating system. Are you certain you're using the correct drivers for the scanner?
0
 
LVL 34

Expert Comment

by:Gary Patterson
ID: 34946279
Not sure what you mean by "can't seem to translate it".  No translation is required.  VBA is VBA.  Doesn't matter if you're using it from Word, Excel, Outlook, Access, whatever.

This fragment is the key section that I think you are looking for.  To determine if a device has an ADF, you loop through the device's Properties collection, and test for:

Property 3087 = ADF
Property 3088 = Page ready in ADF

The code below loops through the device's Properties collection, and if it finds property ID 3087 and 3088, then it means that there is an ADF attached, and at least one more page in the ADF to be scanned.  The boolean values MorePages is set to TRUE if both of these properties are found, and FALSE if they are not both found.

In your code, you just scan a page, and then just repeatedly perform this test to determine if there are more pages to scan.

- Gary Patterson


MorePages = True 
For Each Prop In dev.Properties
   Select Case Prop.PropertyID
      Case 3087 'Document Handling Select (1 = ADF)
         MorePages = MorePages And (Prop.Value = 1)
      Case 3088 'Document Handling Status (1 = Page ready in ADF)
         MorePages = MorePages And (Prop.Value = 1)
    End Select
Next Prop

Open in new window

0
 
LVL 34

Expert Comment

by:Gary Patterson
ID: 34946309
In that link, the "solution" I was actually referring to the example code, not the comments about the driver issue.  

I think krystalj is just looking for a good code example in VBA showing how to scan multiple pages from an ADF, and that is what that code does.

- Gary
0
 

Author Comment

by:krystalj
ID: 34953324
I tried using code recommeded and linked to by Gary the Pro. Unfortuatly it asked for a Macro name when I ran it. Does anyone know where I went wrong/
0
 

Author Comment

by:krystalj
ID: 34953424
One more issue. My clients are hooked up to multiple scanners. I don't know how that is affecting my code. I didn't see any help for wia.selectdevice in VBA
0
 
LVL 34

Accepted Solution

by:
Gary Patterson earned 500 total points
ID: 34953817
krystalj,

Access probably just wants you to give your VBA "macro" a name.  Create a VBA module or class module to hold your code, and then start pasting code into the module you created.

http://office.microsoft.com/en-us/access-help/get-started-with-access-programming-HA001214213.aspx

BTW, this isn't a full program that you can just cut and paste in.  It is a partial program that demonstrates the technique needed to work with an ADF using WIA in VBA.  You need to know at least a little bit about VBA programming in Access in order to use it.  If you don't have much VBA experience in Access, you probably need to get an experienced VBA consultant to help you with the programming details.

You'll need to look in the WIA Automation SDK for the help file (CHM format) for WIA Automation objects.  Download the SDK, extract it, and open the Help file.  If you are on Vista or newer, you'll need to download the Microsoft HTML Help Viewer, since the CHM viewer isn't included with newer versions of Windows.

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=a332a77a-01b8-4de6-91c2-b7ea32537e29
http://msdn.microsoft.com/en-us/library/ms669985%28v=vs.85%29.aspx

You'll need to test your code with each scanner you want to support, to be safe.

- Gary Patterson
0
 

Author Closing Comment

by:krystalj
ID: 34964186
Thank you for your help. I'll get started.

If you can think of any good books on VBA, please let me know. I have not been able to find many
0
 
LVL 34

Expert Comment

by:Gary Patterson
ID: 34964699
Happy to help.  

Go to Amazon.com and search for "VBA".  I got over 2,000 results.

- Gary
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question