XmlHttp Post in Excel VBA not updating website form -
i routinely have search state of nv unclaimed property , put results in excel spreadsheet. trying automate process i'm limited using excel 2010 , vba. below url site i'm trying submit form using xmlhttp.
url: https://nevadatreasurer.gov/upsearch/
i created class automate submitting forms on other websites no matter enter in postdata form never submitted. below submission, , method submit form.
call class:
cxml.openwebsite "post", "https://nevadatreasurer.gov/upsearch/index.aspx", _ "ctl04$txtowner=" & strsearchname
class method:
public sub openwebsite(stropenmethod string, strurl string, _ optional strpostdata string) pxmlhttp.open stropenmethod, strurl if strpostdata <> "" strpostdata = convertspacetoplus(strpostdata) pxmlhttp.setrequestheader "content-type", "application/x-www-form-urlencoded" pxmlhttp.send (strpostdata) else pxmlhttp.send end if 'create dom html documnet phtmlobj.body.innerhtml = pxmlhttp.responsetext end sub
each time responsetext
main website no updates, if submitted no postdata. i'm new ie automation can provide reason why isn't working , code example works?
thanks!
update: 7/26/13 8:30am pst
without changes method able submit forms through website. state of or unclaimed property form. worked perfect!
url: https://oregonup.us/upweb/up/up_search.asp
however ran same problem when tried state of ca unclaimed property website. no matter do, responsetext
original search page no update.
url: https://scoweb.sco.ca.gov/ucp/default.aspx
it still not work state of nv on original post. using proper post data, url encoded each website , can see no difference. appreciated.
try below code
public sub openwebsite(stropenmethod string, strurl string, optional strpostdata string) dim pxmlhttp object set pxmlhttp = createobject("msxml2.xmlhttp") pxmlhttp.open stropenmethod, strurl, false pxmlhttp.setrequestheader "content-type", "application/x-www-form-urlencoded" pxmlhttp.send (strpostdata) dim phtmlobj object set phtmlobj = createobject("htmlfile") phtmlobj.body.innerhtml = pxmlhttp.responsetext msgbox pxmlhttp.responsetext end sub sub test() dim btnsearch string, strsearchtype string, strsearchname string, postdata string btnsearch = "search" strsearchtype = "owner" strsearchname = "santosh" postdata = "ctl04%24txtowner=" & strsearchname & "&ctl04%24btnsearch=" & btnsearch & "&ctl04%24rblsearchtype=" & strsearchtype openwebsite "post", "https://nevadatreasurer.gov/upsearch/index.aspx", postdata end sub
post data view using firebug
url encode
responetext
Comments
Post a Comment