UtterAccess.com
We have detected that you are using an unsupported web browser. We recommend you to upgrade your web browser to get the most from UtterAccess forums.
Why should and how can I upgrade?
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Control scanner with VBA    
 
   
RJS
post Apr 11 2007, 06:47 PM
Post #1

UtterAccess Guru
Posts: 667
From: Arizona



I posted on this subject several months ago and had some luck, but I have changed scanners, and my old code does not work well with the new scanner.
I am trying to scan checks and save them to a file (link is then saved in the database).
I think I am close with this code, but I can not get to the point where I actually save the file. When it scans (@ the line ".Transfer"), I can tell that I have changed the DPI because the scanner runs faster, and I know that it is accepting the check size because it stops after scanning 4 inches.
CODE
Sub testScan1()
Dim wiaImg As New WIA.imagefile
Dim wiaDialog As New WIA.CommonDialog
Dim wiaScanner As WIA.Device
Set wiaScanner = wiaDialog.ShowSelectDevice
With wiaScanner.items(1)
    .Properties("6146").Value = 2 '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
    .Properties("6151").Value = 850 'horizontal exent DPI x inches wide
    .Properties("6152").Value = 400 'vertical extent DPI x inches tall
    .Transfer ("{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}") 'Tif format - This prompts the scan
End With
'
'need help with code here
'
wiaImg.SaveFile ("c:\myimage.tif")  
End Sub

I am getting the error "No ImageFile loaded. You must call LoadFile first" when I get to the line "wiaImg.SaveFile ("c:\myimage.tif")"
I have tried about a hundred different pieces of code before that line, but I can not figure it out.
Are there any experts out there who know how to edit what I have so far?
Rob
Go to the top of the page
 
+
freakazeud
post Apr 11 2007, 08:00 PM
Post #2

UtterAccess VIP
Posts: 31,413
From: NC, USA



Hi,
where do you actually assign any value to wiaImg? You are getting the error because nothing is loaded into it.
HTH
Good luck
Go to the top of the page
 
+
RJS
post Apr 12 2007, 09:57 AM
Post #3

UtterAccess Guru
Posts: 667
From: Arizona



Yes that is the problem.
tried many different ways, and errored out every time. Do you have any insight on how to assign a value to it?
Rob
Go to the top of the page
 
+
RJS
post Apr 12 2007, 11:21 AM
Post #4

UtterAccess Guru
Posts: 667
From: Arizona



The closest I can get is with this:
et wiaImg = wiaScanner.WiaItem()
When that line is inserted, I get the error "Type mismatch", which makes me think I am close, but I can not get any closer.
Rob
Go to the top of the page
 
+
freakazeud
post Apr 12 2007, 03:30 PM
Post #5

UtterAccess VIP
Posts: 31,413
From: NC, USA



Hi,
I think you want to assign the value at the .transfer part e.g.:
iaImg = CType(.Transfer(format),WIA.ImageFile)
You just need to adjust the format. I can't really test this but it should help you further.
HTH
Good luck
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Search  ·  Go to Top  ·  Lo-Fi Version Time is now: 20th September 2014 - 04:59 PM