Solved

ADF Scanner In Access Using VBA and WIA

Posted on 2011-02-21
11
3,391 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 74

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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
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…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now