Excel VBA getting captcha - bad version of image -




i'm getting captcha image webpage , inserting excel cell, manually proceding captcha writing inputbox in excel, excel pass captcha text opened ie window.

so every element of code works fine, i'm getting 1 version of captcha image on opened ie window , diffrent 1 inserted excel.

why ? looks diffrent instance of ie opened , diffrent instance of ie used inserting captcha image excel.

sub get_captcha() dim ie new internetexplorer  ie.visible = true ie.navigate activecell  doevents loop until (ie.readystate = 4 , not ie.busy)  dim doc htmldocument set doc = ie.document dim myinput string  captcha = doc.getelementbyid("maincontent_ctrlcaptcha").getattribute("src") activecell.offset(0, 2).value = captcha  activesheet.pictures  .insert (doc.getelementbyid("maincontent_ctrlcaptcha").getattribute("src")) end end sub 

diffrent approach screen capturing

sub get_captcha()  application.displayalerts = false: application.screenupdating = false: application.enableevents = false     on error goto cleanup  dim clipboard msforms.dataobject set clipboard = new msforms.dataobject clipboard.clear  dim ie new internetexplorer ie.visible = true ie.navigate activecell.value  doevents loop until ie.readystate = readystate_complete  dim doc htmldocument set doc = ie.document dim myinput string  captcha = doc.getelementbyid("maincontent_ctrlcaptcha").getattribute("src") activecell.offset(0, 2).value = captcha  sleep (500) application.sendkeys "(%{1068})" sleep (500) ie.quit  dim shp shape  activesheet.paste destination:=activesheet.range(activecell.offset(0, 0), activecell.offset(-12, -8)), link:=false activesheet set shp = .shapes(.shapes.count)     shp.pictureformat.cropright = 500     shp.pictureformat.cropbottom = 330     shp.pictureformat.croptop = 150     shp.pictureformat.cropleft = 278 end  activecell.offset(1).select  cleanup:     application.displayalerts = true: application.screenupdating = true: application.enableevents = true end sub 





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -