I'm submitting a form using Excel VBA while using an InternetExplorer object. Once submitted, I can see the URL change on screen. However, when I attempt to output the URL (to confirm that it changed and the code knows it), I get the same URL.
In both debug statements below, they output the same URL.
Code:
Dim username As String
Dim password As String
Dim server_ip As String
username = "aaa"
password = "bbb"
server_ip = "ip_here"
Dim ie As New InternetExplorer
Dim doc As HTMLDocument
Set doc = New MSHTML.HTMLDocument
Dim url As String
ie.Visible = True
ie.navigate "my_url"
'wait
Do
DoEvents
Loop Until ie.readyState = READYSTATE_COMPLETE
Set doc = ie.document
Debug.Print "url: " & doc.url ' is /abc.html
'set credentials
doc.all.username.Value = username
doc.all.password.Value = password
'submit
ie.document.getElementsByTagName("form")(0).submit
Debug.Print "submitted..."
'wait
Do
DoEvents
Loop Until ie.readyState = READYSTATE_COMPLETE
Set doc = ie.document
Debug.Print "url: " & doc.url 'should be /def.html, but returns /abc.html