Scan image in vba with cannon scanner not work -
i have vba code scan image scanner , code works , doesnt have problem type hp brother scanner when used canon can not find scanner , send message no wia device. how can solve problem
private sub command10_click() const wiaformatjpeg = "{b96b3cae-0728-11d3-9d7b-0000f81ef32e}" on error goto handle_err dim dialog1 new wia.commondialog, dpi integer, pp integer, l integer dim scanner wia.device dim img wia.imagefile dim intpages integer dim strfilejpg string dim blncontscan boolean ' activate scanner start scan dim contscan string 'msgbox chk if more pages scanned dim strfilepdf string dim rptname string dim strprocname string strprocname = "scandocs" docmd.setwarnings false docmd.runsql "delete scantemp" docmd.setwarnings false blncontscan = true intpages = 0 while blncontscan = true dpi = 200 pp = 1 'no of pages set scanner = dialog1.showselectdevice(wia.wiadevicetype.scannerdevicetype, true, false) set img = dialog1.showtransfer(scanner.items(1), wiaformatjpeg, true) strfilejpg = "" intpages = intpages + 1 strfilejpg = "\\user-pc\saveimage\" & num & trim(str(intpages)) & ".jpg" img.savefile (strfilejpg) docmd.runsql "insert scantemp (picture) values ('" & strfilejpg & "')" docmd.setwarnings false set scanner = nothing set img = nothing ' strfilejpg = "" 'prompt user if there additional pages scan contscan = msgbox("?save page ", vbquestion + vbyesnocancel) if contscan = vbno blncontscan = false elseif contscan = vbcancel docmd.runsql "delete scantemp picture = '" & strfilejpg & "'" end if ''''''''''''''' loop dim image_path string goto startpdfconversion startpdfconversion: dim s string strfilepdf = "\\user-pc\saveimage\" & (num) & ".pdf" rptname = "rptscan" docmd.openreport rptname, acviewreport, , , achidden docmd.close acreport, rptname, acsaveyes docmd.outputto acoutputreport, rptname, acformatpdf, strfilepdf me.imgp = strfilepdf docmd.runsql "delete scantemp" 'delete data table scantemp after converted pdf '/*******************************\ '/********************************************\ handle_exit: exit sub handle_err: select case err.number case 2501 resume handle_exit case else msgbox "the." & vbcrlf & vbcrlf & _ "in function:" & vbtab & strprocname & vbcrlf & _ "err number: " & vbtab & err.number & vbcrlf & _ "description: " & vbtab & err.description, 0, _ "error in " & chr$(34) & strprocname & chr$(34) resume handle_exit end select exit sub end sub
option compare database private declare function twain_acquiretofilename lib "twain32d.dll" (byval hwndapp long, byval bmpfilename string) integer private declare function twain_isavailable lib "twain32d.dll" () long private declare function twain_selectimagesource lib "twain32d.dll" (byval hwndapp long) long private sub cmdscan_click() dim ret long, picturefile string dim intpages integer dim blncontscan boolean dim contscan string 'msgbox chk if more pages scanned blncontscan = true intpages = 0 while blncontscan = true dpi = 200 pp = 1 'no of pages intpages = intpages + 1 picturefile = currentproject.path & "\" & myfolder & "\" & me.number & trim(str(intpages)) & ".jpg" ret = twain_acquiretofilename(me.hwnd, picturefile) contscan = msgbox("? ÍÝÙ ÕæÑÉ ÇÎÑì ", vbquestion + vbyesno, "ÊäÈíÉ") if contscan = vbno blncontscan = false end if loop
Comments
Post a Comment