Thursday, 15 May 2014

internet explorer - Clicking buttons in IE with VBScript on CRA website -



internet explorer - Clicking buttons in IE with VBScript on CRA website -

i’m new vbscript , i’m trying automate payroll calculations through cra website http://www.cra-arc.gc.ca/esrvc-srvce/tx/bsnss/pdoc-eng.html in excel. i’m been trying figure out few days no luck. think problem simple: i’m trying click on “i take button” @ bottom of page of website above.

the code i’ve written below next line don’t know how click button. error here whatever try.

objie.application.document.getelementbyid("??????").click

the html code below has no id. i’ve tried various other things getelementbytype, getelementbyvalue no luck

vbscript

sub test() set objie = createobject("internetexplorer.application") objie.application.visible = true objie.application.navigate "http://www.cra-arc.gc.ca/esrvc-srvce/tx/bsnss/pdoc-eng.html" while objie.application.busy or _ objie.application.readystate <> 4 doevents loop objie.application.document.getelementbyid("??????").click while objie.application.busy or _ objie.application.readystate <> 4 doevents loop end sub

html code

<div class="aligncenter"> <input type="button" title="i take - begin calculation" value="i accept" onclick="parent.location='https://apps.cra-arc.gc.ca/ebci/rhpd/startlanguage.do?lang=english'" /> <input type="button" title="i not take - homecoming payroll" value="i not accept" onclick="parent.location='/tx/bsnss/tpcs/pyrll/menu-eng.html'" /> </div>

i appreciate someones help.

thanks,

matthew

note vb/vba doevents function not available in vbscript. however, here working code.

call test sub test() createobject("internetexplorer.application") .visible = true .navigate "http://www.cra-arc.gc.ca/esrvc-srvce/tx/bsnss/pdoc-eng.html" while .busy or .readystate <> 4 wscript.sleep 50 loop set oinputs = .document.getelementsbytagname("input") each elm in oinputs if elm.value = "i accept" elm.click exit end if next while .busy or .readystate <> 4 wscript.sleep 50 loop end end sub

internet-explorer button vbscript getelementbyid

No comments:

Post a Comment