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.

enter image description here

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

enter image description here


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -