excel - Open a Document in IE and be able to store it as a variable in vbs -
i trying write vbs program navigate web page, click on link opens file in excel, run macro in excel file. know how navigate web page , click on link. need figuring out how store excel file in way vbs program can manipulate it.
set ie = wscript.createobject("internetexplorer.application", "ie_") ie.visible = true ie.navigate ("https://www.whateverwebsite.com/") dim linkhref linkhref = "analyze" 'the key word in link click dim each in ie.document.getelementsbytagname("a") ' every element tag name starts 'a' "a href" pull out contents if instr((a.getattribute("href")), linkhref)>0 'checks see if link set contains string stored in linkhref a.click 'click link end if next dim objexcel set objexcel = createobject("excel.application") now how attach excel file, opened link, objexcel?
you can attach running excel instance via getobject:
set xl = getobject(, "excel.application") if have several instances launched, first one, though. you'd have terminate first instance second one.
with said, better approach have excel open url directly:
set xl = createobject("excel.application") each in ie.document.getelementsbytagname("a") if instr(a.href, linkhref) > 0 set wb = xl.workbooks.open(a.href) exit end if next
Comments
Post a Comment