Solved

Access - Control button to Launch a Scanner app

Posted on 2014-01-05
8
167 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

820 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