Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
WIA Sanner Scripting to a Document Feeder
Message
 
To
All
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
WIA Sanner Scripting to a Document Feeder
Miscellaneous
Thread ID:
00966536
Message ID:
00966536
Views:
73
How do I use the WIA scripting host to tell the scanner to scan from the document feeder? The following code works for scanning an image, but it only scans the 1st page:
LOCAL lnDeviceCount,lnDeviceNum,loWia,loItem,loImages,loImage,lnCntr,lcFname,loFileCollection,lnNewPk
lnDeviceNum=0
TRY
	loFileCollection=CREATEOBJECT('collection')
	loWia = CreateObject("Wia.Script")
	lnDeviceCount=loWia.Devices.Count
	IF lnDeviceCount#1
		IF lnDeviceCount=0
			=MESSAGEBOX("There are no recognized document imaging devices attached to your computer",48,"Scan Aborted")
			RETURN .T.
		ELSE
			=MESSAGEBOX("There are "+TRANSFORM(lnDeviceCount)+" recognized imaging devices on your computer."+CHR(10)+"Using: "+loWia.Devices(0).name,48,"Scanner Selection")
		ENDIF 
	ENDIF 
	loItem = loWia.Create(lnDeviceNum) && Item object represents WIA hardware device
	loImages=loItem.GetItemsFromUI(0,0)
	IF VARTYPE(loImages)='O'
		lnCntr=0
		FOR EACH loImage IN loImages
			lnCntr=lnCntr+1
			lcFname=[C:\Temp\]+[ScanImage]+PADL(lnCntr,3,'0')+[.bmp]
			WAIT WINDOW NOWAIT 'Scanning to ...'+CHR(13)+lcFname
			loImage.Transfer(lcFname,.F.)
			IF FILE(lcFname)
				loFileCollection.add(lcFname,JUSTFNAME(lcFname))
			ENDIF 
		ENDFOR 
	ENDIF 
	WAIT CLEAR
	IF loFileCollection.count>0
         * Do something the the file collection...
	ENDIF 
CATCH TO oErr
	=MESSAGEBOX(oErr.Message,48,'Windows Imaging not Available')
ENDTRY 
Reply
Map
View

Click here to load this message in the networking platform