Solved

ADF Scanner In Access Using VBA and WIA

Posted on 2011-02-21
11
3,520 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 35

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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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 35

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 35

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 35

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 35

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
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.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

762 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