My code opens a page and starts to complete it. It then clicks on a button which results in a pop-up screen that needs to be completed. However, I'm not sure how to make my code access that pop up screen. Any help would be appreciated!
Here is my code:
Sub Van()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.navigate ("website")
IE.Visible = True
Do
DoEvents
Loop Until IE.readystate = 4
Set d = IE.document
'Code clicks on buttons and dropdowns
Application.Wait (Now + TimeValue("00:00:03"))
d.GetElementbyid("caravanMake").Value = "JAY"
End Sub
This worked for me to set the value of the first drop-down in the pop-up:
'...
Application.Wait (Now + TimeValue("00:00:03"))
Set IE2 = GetIE("https://secure.apia.com.au/NASApp/apia/CRQuoteServlet?" & _
"pageAction=openModelSelectionWindow¤tSequenceNumber=")
IE2.document.getElementsByTagName("select")(0).Value = "JAY"
'etc
Function to find an open window with a given URL:
'Find an IE window with a matching URL
'Assumes no frames.
Function GetIE(sAddress As String) As Object
Dim objShell As Object, objShellWindows As Object, o As Object
Dim retVal As Object, sURL As String
Set retVal = Nothing
Set objShell = CreateObject("Shell.Application")
Set objShellWindows = objShell.Windows
'see if IE is already open
For Each o In objShellWindows
sURL = ""
On Error Resume Next
sURL = o.LocationURL
On Error GoTo 0
If sURL <> "" Then
'Debug.Print sURL
If sURL = sAddress Then
Set retVal = o
Exit For
End If
End If
Next o
Set GetIE = retVal
End Function