简体   繁体   中英

Write to Internet Explorer javascript console with vba in excel

i'm trying to send a simple http post request. It works perfectly fine if I send it via the Internet Explorer console using ajax, but i'm having problems doing it in VBA. I've identified that the problem is the proxy server of the company i'm working at. It only allows configured software to access the internet. So my VBA script gets blocked, but everything works fine with Internet Explorer. Is there anyway I can simply write directly into the Internet Explorer Console and send the http post request from there via ajax?

Thank you for any help!

not meant as an answer

this is taken from the object browser

navigate method of the InternetExplorer object

Sub Navigate(URL As String, [Flags], [TargetFrameName], [PostData], [Headers])
Member of SHDocVw.InternetExplorer
Navigates to a URL or file.

so maybe this object might work CreateObject("InternetExplorer.Application")

the microsoft site mentions that POST method is used if data is in the PostData argument, otherwise the GET method is used

https://msdn.microsoft.com/en-us/library/aa752093(v=vs.85).aspx

PS: the OP found this call that solved the problem with calling AJAX, as per comment from OP

IE.document.parentWindow.execScript("javascript_code()", "JavaScript")

quick example ...

IE.Document.parentWindow.execScript "alert('Arbitrary javascript code')", "javascript"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM