Capturing and saving images using WIA (1 Viewer)

Mike_Burns67

Registered User.
Local time
Today, 07:40
Joined
Oct 8, 2008
Messages
11
Hi all

Long time reader, first time poster ;-)

I've been struggling with a piece of code for Access for a few days and am totally stuck.

I have a piece of code (thank you utteraccess.com) that opens the dialog box up for a PnP scanner I have connected to this PC; the code is;

'---
Dim commondialog1 As Object
Dim img As image
Set commondialog1 = CreateObject("wia.commondialog")
Set img = commondialog1.showacquireimage
img.savefile ("c:\test.jpg")
'---

the first 3 lines work perfectly, the scanner's dialog box loads and allows me to scan an image, but as soon as the scan is complete I get a "runtime error 13" on line 4

Also the savefile bit on line 5 doesnt seem to be recognised as a valid method so I'm guessing even if it didnt error on line 4 it would not be happy anyway.

Lastly, and this may be the crux of the matter...

I downloaded and registered the WIA DLL from Microsoft, but it doesnt appear in the ActiveX controls as WIA library 2.0 - as Microsoft suggests, but the DLL is showing as the control for the "commondialog class", the "devicemanager class" and the "wia video preview class".

Can anyone shed any light on this?
 

CyberLynx

Stuck On My Opinions
Local time
Yesterday, 23:40
Joined
Jan 31, 2008
Messages
585
The WIA (Windows Image Acquisition Automation Library v2.0 Tool for hose that care to know).

If the WIA is properly installed and Registered you should be able to see the Windows Image Acquisition Automation Library v2.0l within the IDE's Reference list. Make sure it's check marked

The best place to install (copy/paste) this DLL is to copy it into the \Windows\System32\ directory (Folder). To register this DLL you need to use the RegSrv32.exe file which also is usually found within the \Windows\System32\ directory:

Windows Start Button | Run | cmd and hit Enter

at the Windows DOS prompt enter:

cd c:\windows\system32

then again at the DOS prompt enter:

regsrv32 WIAAut.dll

You will get a confirmation message box indicating that the DLL is indeed registered.

This is of course assuming that you did copy/paste the WIAAut.dll file into the C:\Windows\System32\ directory and RegSrv32.exe resides there as well.

Now select it from the IDE References Window then try this code.

Try this instead:

Code:
Dim commondialog1 As Object
Dim img As [B][COLOR="Blue"]ImageFile[/COLOR][/B]
Set commondialog1 = CreateObject("wia.commondialog")
Set img = commondialog1.ShowAcquireImage

img.SaveFile ("c:\test.jpg")

.
 

Mike_Burns67

Registered User.
Local time
Today, 07:40
Joined
Oct 8, 2008
Messages
11
Thanks for the suggestion Cyberlink, but it still didnt work..

I had already registered the DLL but i did it again just to be sure - both via the run command itself and at the dos-promt as you suggested. It still doesnt show up in the activeX control list.

Isnt the IDE reference a fox-pro thing, not an access thing?

Mike.
 

Mike_Burns67

Registered User.
Local time
Today, 07:40
Joined
Oct 8, 2008
Messages
11
Ignore my last post, i've found it.

You have browse for it in Tools/References on the VBA menu, then tick it and it works.

Thanks for your help CyberLinx.

Mike.
 

CyberLynx

Stuck On My Opinions
Local time
Yesterday, 23:40
Joined
Jan 31, 2008
Messages
585
Good show Mike.

The IDE (Integrated Development Environment) is the VBA Editor which you now know :)
 
Last edited:

craigachan

Registered User.
Local time
Yesterday, 23:40
Joined
Nov 9, 2007
Messages
282
I've tried the code above and it works great when in Access 2007. But when I tried in runtime, it errored out. It helped me to get a little further by placing the wiaaut.dll in the system32 directory on the workstation that I'm running the runtime version. But I still get an error. It seems to hang up on the ShowAcquireImage line.

Any suggestions?
 

CyberLynx

Stuck On My Opinions
Local time
Yesterday, 23:40
Joined
Jan 31, 2008
Messages
585
What was the Error you received? This could very well be helpful in this case.

.
 

craigachan

Registered User.
Local time
Yesterday, 23:40
Joined
Nov 9, 2007
Messages
282
ActiveX Component can't create Object.
Object Variable or with block not set.
 

CyberLynx

Stuck On My Opinions
Local time
Yesterday, 23:40
Joined
Jan 31, 2008
Messages
585
It seems as though you do not have the Windows Image Acquisition Automation Library v2.0l Library referenced within your VBA Editor. Read the earlier posts.

.
 

craigachan

Registered User.
Local time
Yesterday, 23:40
Joined
Nov 9, 2007
Messages
282
But the WIA Library does show up in References in the VB Editor. It's checked, i see it in the system32 directory....But when I try to re-register it I get an error registering it.
 

CyberLynx

Stuck On My Opinions
Local time
Yesterday, 23:40
Joined
Jan 31, 2008
Messages
585
Well Craig...I really can't help you much with this one then. It must be something within the Access 2007 Runtime module(s) that's causing this to go a little wonky. You may need to take this up with Microsoft.

.
 

Users who are viewing this thread

Top Bottom