excel - Compilation Error with small script -
i'm trying write cls in excel 2007, here's code:
dim jiraservice msxml2.xmlhttp60 set jiraservice = new msxml2.xmlhttp60 jiraservice.open "get", "url", false jiraservice.setrequestheader "content-type", "application/json" jiraservice.setrequestheader "accept", "application/json" jiraservice.send srestresponse = jiraservice.responsetext msgbox srestresponse
i'm getting compilation error, indicating set appears invalid.
it says external procedure not valid.
can me out?
you missing appropriate reference guess. click on tools~~>references in vba
add project references to;
- microsoft winhttp services, version 5.1
- microsoft xml, v6.0
also in line
jiraservice.open "get", "url", false
if url
variable holds actual url "url"
considered string , not variable since between quotes. guess trying this?
jiraservice.open "get", url, false
followup (from comments)
the problem have pasted above code in class module. suppose paste code in module , call in sub. see example
sub sample() dim jiraservice msxml2.xmlhttp60 set jiraservice = new msxml2.xmlhttp60 jiraservice.open "get", url, false jiraservice.setrequestheader "content-type", "application/json" jiraservice.setrequestheader "accept", "application/json" jiraservice.send srestresponse = jiraservice.responsetext msgbox srestresponse end sub
screenshot
Comments
Post a Comment