frigorific
New Member
- Joined
- Jan 7, 2010
- Messages
- 1
Hi all, a tough one I'm struggling with, for a kind soul Excel VBA guru if there is one reading!
I'm using WinHttp to access from Excel VBA an URL, say "http://server/application?id=abc".
When I open this URL from Explorer, I get an HTML table with lots of info. The idea is to parse the table contents and fill some cells in my spreadsheet with the values received.
However when I try from Excel VBA with code like this:
Dim ht As New WinHttp.WinHttpRequest
ht.Open "POST", "http://server/application?id=abc", False
ht.SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
ht.SetRequestHeader "Content-Type", "multipart/form-data; "
ht.Send
</PRE>
I obtain the following ht.ResponseText:
[script language="javascript" type="">
function submitForm() {
document.form1.submit();
}
[/script>
[html>
[body bgcolor="#FFFFFF" ******="submitForm()">
[font size="20" color="blue">Loading. Please wait.</font>
[form NAME="form1" ACTION="dispatch" METHOD="post">
[INPUT TYPE="hidden" name="action" value="response">
[INPUT TYPE="hidden" name="user_id" value="user">
[/FORM>
[/body>
[/html>
</PRE>
So it looks like it sets a couple of hidden parameters on a form and then submits itself upon load.
I've tried various things to no avail, for example adding those hidden fields like this:
Dim login As String
login = "action=response&user_id=user"
...
ht.Send login
</PRE>
But it doesn't do what I want it to do, which is to submit the form and present the response.
So my question is: How can I construct the WinHttp send request so that I obtain the response from the submitted form, and not the form itself?
My brain is hurting now so if anyone has any pointers on how to do this, it'll be most appreciated! Thanks in advance.
I'm using WinHttp to access from Excel VBA an URL, say "http://server/application?id=abc".
When I open this URL from Explorer, I get an HTML table with lots of info. The idea is to parse the table contents and fill some cells in my spreadsheet with the values received.
However when I try from Excel VBA with code like this:
Dim ht As New WinHttp.WinHttpRequest
ht.Open "POST", "http://server/application?id=abc", False
ht.SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
ht.SetRequestHeader "Content-Type", "multipart/form-data; "
ht.Send
</PRE>
I obtain the following ht.ResponseText:
[script language="javascript" type="">
function submitForm() {
document.form1.submit();
}
[/script>
[html>
[body bgcolor="#FFFFFF" ******="submitForm()">
[font size="20" color="blue">Loading. Please wait.</font>
[form NAME="form1" ACTION="dispatch" METHOD="post">
[INPUT TYPE="hidden" name="action" value="response">
[INPUT TYPE="hidden" name="user_id" value="user">
[/FORM>
[/body>
[/html>
</PRE>
So it looks like it sets a couple of hidden parameters on a form and then submits itself upon load.
I've tried various things to no avail, for example adding those hidden fields like this:
Dim login As String
login = "action=response&user_id=user"
...
ht.Send login
</PRE>
But it doesn't do what I want it to do, which is to submit the form and present the response.
So my question is: How can I construct the WinHttp send request so that I obtain the response from the submitted form, and not the form itself?
My brain is hurting now so if anyone has any pointers on how to do this, it'll be most appreciated! Thanks in advance.
Last edited: