in my Access & VBA application i Have to get and manage a web page of a web order application. Normally, I use the solution indicated in this post, which normally works perfectly:
VBA Open web page, login and get the opened page
But, now I have another old web application to connect with my Access software. In this web application, after login, the web page closes itself and open an other browser session with the first user page. In other words:
1) The user fill the login form with the user credentials 2) After login, the login web page closes the browser 3) An other browser session opens with the web app control panel
If I use the linked solution, I see an error. How can I get the new web page, in the new browser session, which opens it self after login?
Thanks!
EDIT
I have tried the following code (my purpose is set a text value in the web page). But, very strange, it works only if I put a text box in my code: maybe the code must wait some event! How can I solve it?
Dim SWs As SHDocVw.ShellWindows, vIE As SHDocVw.InternetExplorer
Dim winShell As Shell
Dim dt As Date
dt = DateAdd("s", 10, DateTime.Now)
Dim ieA As InternetExplorer
Dim IeDocA As HTMLDocument
Do While dt > DateTime.Now
Set winShell = New Shell
For Each ieA In winShell.Windows
If ieA.LocationURL = sURL Then
ieA.Visible = True
ieA.Silent = True
Do While ieA.Busy: DoEvents: Loop
Do Until ieA.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
Set IeDocA = ieA.Document
//only with this msgbox it works, how can I do this w/out it?
MsgBox IeDocA.title
With IeDocA
.getElementsByName("text").value="something"
End With
Set winShell = Nothing
Exit Do
End If
Next ieA
Set winShell = Nothing
DoEvents
Loop
You can Look for the URL in the window. You will need a reference to Microsoft Shell Controls and Automation.