1 year ago
#371957
SixSigmaGuy
Why can't I set the WIA Scanner "Page Size" property to auto size?
I can seem to do everything else just fine with my scanner, using WIA and VBA, but when I try to set my scanner to detect the page size, I get an error message "The parameter is incorrect." I've searched extensively for a solution without any luck. Someone else asked a similar question here 11 years ago (Set page size using WIA (with scanner)), but the answer didn't really address my question and later comments claimed the solution didn't work. Here's a code snippet I created to demonstrate my problem. In the snippet I first set another property (the "pages" property) to show that I can set properties, but the "page size" property doesn't work.
Sub SetScannerToAutoSize(DeviceID As String)
Dim wiaScanner As WIA.Device
Dim wiaDM As New WIA.DeviceManager
Set wiaScanner = wiaDM.DeviceInfos(DeviceID).Connect ' DeviceID is "{6BDD1FC6-810F-11D0-BEC7-08002BE2092F}\0003"
wiaScanner.Properties.Item(wiaDocumentHandlingSelect).Value = WIA_FEEDER + WIA_DUPLEX ' This works fine setting it to do double-sided scanning
wiaScanner.Properties.Item(wiaPages).Value = WIA_ALL_PAGES ' Works -- wiaPages = "3096", WIA_ALL_PAGES = 1 Tells the scanner to scan all the pages in the feeder.
'
' Next line results in "Run-time error '-2147024809 (80070057)': - The parameter is incorrect"
'
wiaScanner.Properties.Item(wiaPageSize).Value = WIA_PAGE_AUTO ' Doesn't work -- wiaPageSize = "3097", WIA_PAGE_AUTO = 100 'I expected it to tell the scanner to detect the page size
End Sub
According to the device info for the scanner, it is capable of performing this feature. It's a "Brother ADS-1700W LAN" scanner. I also tried it on my EPSON WF-2750 scanner with the same results.
I hope someone can tell me what I'm doing wrong. I need to deliver my app soon.
I'm also trying to get the SDK from Brother, but so far no luck.
excel
vba
scanning
wia
page-size
0 Answers
Your Answer