I am having trouble finding out how to get excel VBA to interact with a specific IE Window that is already open.
Here my process:
I open IE, navigate to the website, enter my username and pw, click log in. A new IE window opens that I use to enter member numbers and search for membership info.
I am trying to create a VBA script that will interact with the IE window that opens after I successfully log in (to begin to automate some of the more mundane tasks). I have seen tons of tutorials online about how to have VBA open a new IE window, and then interact with it. However, I am really struggling to find info about how to select a specific already open IE window and interact with it.
I have tried this as a quick test to see if I could select the correct IE window as an object that I can interact with.
Sub getIE()
Dim sh As Object, oWin As Object, IE As Object
Set sh = CreateObject("Shell.Application")
For Each oWin In sh.Windows
If TypeName(oWin.document) = "HTMLDocument" Then
Set IE = oWin
Exit For
End If
Next
MsgBox IE.document.URL
End Sub
The message box appears and shows the URL for initial IE window, but I don't know how to get it to select the IE window that I typically use to actually get member info.
I took several technical classes years ago when I was in school, but has been a while since I have flexed any tech muscles. Any help would be greatly appreciated!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…