Solved

Access - Control button to Launch a Scanner app

Posted on 2014-01-05
8
112 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:wlwebb
Comment Utility
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

Expert Comment

by:Jim Dettman (Microsoft MVP/ EE MVE)
Comment Utility
<<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
Comment Utility
Thanks Jim,
Giving it a try
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

771 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

11 Experts available now in Live!

Get 1:1 Help Now