WIA Scripting

N

Nick Bell

Hi chaps,

I'm trying to use the Windows Image Acquisition scripting model described
at:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wia/wia/ref
script1/wiascriptingmodel.asp

.... To grab an from a TWAIN scanner. I'm amazed and happy that the following
subroutine grabs an image from the scanner and saves it to c:\ on XP
Pro/Office XP:
---------------
Dim objWia
Dim objDeviceInfoCollection
Dim objDeviceInfo
Dim objRootItem
Dim objSelectedItems
Dim objItem

Set objWIA = CreateObject("Wia.Script")

Set objDeviceInfoCollection = objWia.Devices

For Each objDeviceInfo In objDeviceInfoCollection
Set objRootItem = objWia.Create(objDeviceInfo)
Set objSelectedItems = objRootItem.GetItemsFromUI(0, 0)
For Each objItem In objSelectedItems
objItem.Transfer("c:\Folder\Filename.bmp")
Next
Next
----------------
Now I'd like to use the OnTransferComplete sub as stated below on this page:

http://msdn.microsoft.com/library/en-us/wia/wia/refscript1/events/_iwiaevent
s/ontransfercomplete.asp

"WIA notifies the script or application when a data transfer, image or
sound, completes successfully. Implement the objWia_OnTransferComplete()
subroutine to allow your script or application to respond to the completion
of the data transfer."

Where do I plumb the event in to Access VBA? I've tried creating a sub
called objItem_OnTransferComplete, and another called
objWIA_OnTransferComplete, but neither capture it.

I'm very grateful for any advice anyone is able to offer

Nick
 
J

John Griffiths

You need something like

Option Explicit
Private WithEvents objWIA As Wia.Script

at the top of the module.

A module has two combo boxes at the top.
Selecting objWIA in the left will set the event signatures in the right.

choose OnTransferComplete from the right combo and away you go.

WIA not on my w2k machine but I assume it is a replacement for
the Wang/Kodak Image Scan Control.

Regards John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top