Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 285
  • Last Modified:

Access - Control button to Launch a Scanner app

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
wlwebb
Asked:
wlwebb
  • 3
  • 2
2 Solutions
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
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
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
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
 
wlwebbAuthor Commented:
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now