Solved

Access - Control button to Launch a Scanner app

Posted on 2014-01-05
8
198 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
[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
  • 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

734 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