Solved

Access - Control button to Launch a Scanner app

Posted on 2014-01-05
8
133 Views
Last Modified: 2016-05-16
Hello all.

Don't have any idea if this can be done or not.

I have a scanner that I would like to employ in my db app to scan docs.  I don't want the doc itself to be added to the db, just a String of the location of the scanned doc.  I envision creating a table to store the file name as a String into that table.

My question is on a Control Button how do you Launch the particular Scanner's scan function.

The particular Scanner being used is a Canon All in One which has it's own "Toolbox" which auto launches when you select the actual scan function on the All in One.

I've scanned around trying to find other threads and read about OCX and DLL files that I'll have to use but not sure how to go about.
0
Comment
Question by:wlwebb
  • 3
  • 2
8 Comments
 
LVL 84

Assisted Solution

by:Scott McDaniel (Microsoft Access MVP - EE MVE )
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 250 total points
ID: 39757373
You can use the Shell function to launch an external application, but you have to know how to do that. For example, if I have an executable file located in C:\MyApp\Folder1 named "scan.exe", I could launch it like this:

Shell "C:\MyApp\Folder1\scan.exe"

However, determining where that items is scanned is a different matter. Your "scan.exe" utility would have to give you this, and there's no way for us to know if that is viable or not.

Some printers/scanners have an API that you can use to interact with them, but in general those are higher-level machines. You can contact Canon to see if your specific printer, or if the "toolbox" stuff you have, is able to be manipulated in that fashion.
0
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 250 total points
ID: 39757452
There are two general approaches:

1. Call an application progamming interface that the MFG or a 3rd party provices (.OCX or DLL).

2. Use one of the API through Windows.

  Windows has three basic ways of talking to scanners:
  a. TWIAN
  b. Windows Image Acquistion API
  c. Windows Portable Devices API

  Those are listed from oldest to newest.  TWAIN is almost gone.   WIA is quite popular now, and WPD is the latest and greatest, but not in widespread use as yet.

  I would shoot for WIA.  You'll need to set a reference to the WIA lib in tools/referencs in the VBA editor.   Once that's done, you'lll be able to call the common dialog to select a device, then issue a command to have it scan.

You code will look something like this:

Sub TestScan1()

Dim strMyPath as string
Dim wiaImg As New WIA.ImageFile
Dim wiaDialog As New WIA.CommonDialog
Dim wiaScanner As WIA.Device

strMyPath = "C:\"

Set wiaScanner = wiaDialog.ShowSelectDevice

With wiaScanner.Items(1)
    .Properties("6146").Value = 4 '4 is Black-white,gray is 2, color 1 (Color Intent)
    .Properties("6147").Value = 100 'dots per inch/horizontal
    .Properties("6148").Value = 100 'dots per inch/vertical
    .Properties("6149").Value = 0 'x point where to start scan
    .Properties("6150").Value = 0 'y-point where to start scan

    'Following is A4 paper size. _
     (Not 100% accurate because real A4 Ht errors)

    .Properties("6151").Value = 830 'horizontal exent DPI x inches wide
    .Properties("6152").Value = 1167 'vertical extent DPI x inches tall

    Set wiaImg = .Transfer(wiaFormatJPEG) 'Change file type in save to match format
End With

'*************************************************************
'Between asterisk lines is because Save errors if file exists
If Dir(strMyPath & "\MyImage.jpg") <> "" Then
  Kill strMyPath & "\MyImage.jpg"
End If
'**************************************************************

wiaImg.SaveFile (strMyPath & "\MyImage.jpg")

Set wiaImg = Nothing
Set wiaScanner = Nothing

End Sub


You can find full documentation on the WIA lib here:

http://msdn.microsoft.com/en-us/library/windows/desktop/ee663303(v=vs.85).aspx

Jim.
0
 

Author Comment

by:wlwebb
ID: 39757542
Thanks to both.......
I will contact Canon as well has play around with the code you posted to see if it can do with I'm wanting..


Thanks....

I will post back but it may be later tomorrow.
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

Author Comment

by:wlwebb
ID: 39774346
Jim

I attempted the code but I'm hitting a Compile error "user-defined type not defined.

Bombs on the Dim wiaImg as New WIA.ImageFile

Is there a "Reference" I have to enable?  I looked for Windows Image Acquisition and Microsoft Windows Image Acquisition but don't see anything I would need to enable.

??????
0
 
LVL 57
ID: 39774828
<<Is there a "Reference" I have to enable?  I looked for Windows Image Acquisition and Microsoft Windows Image Acquisition but don't see anything I would need to enable.
>>

 Yes, you have to add the reference in VBA for the lib.

 The reference is "Microsoft Windows Image Acquistion Library ver n.n"

Jim.
0
 

Author Comment

by:wlwebb
ID: 39775880
Thanks Jim,
Giving it a try
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

911 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

19 Experts available now in Live!

Get 1:1 Help Now