How Excel VBA Controlling IE local intrenet?
We might also need to use the InternetExplorerMedium object as opposed to the InternetExplorer object.
- References for MS Office VBA:
- Microsoft Internet Controls
- Microsoft Shell Controls and Automation
Dim IE As InternetExplorerMedium ' This object (the "medium" variety as opposed to "InternetExplorer") is necessary in our security climate Dim targetURL As String Dim webContent As String Dim sh Dim eachIE targetURL = "[your URL here]" Set IE = New InternetExplorerMedium IE.Visible = False ' Set to true to watch what's happening IE.Navigate targetURL While IE.Busy DoEvents Wend Do Set sh = New Shell32.Shell For Each eachIE In sh.Windows If InStr(1, eachIE.LocationURL, targetURL) Then Set IE = eachIE 'IE.Visible = False 'This is here because in some environments, the new process defaults to Visible. Exit Do End If Next eachIE Loop Set eachIE = Nothing Set sh = Nothing While IE.Busy ' The new process may still be busy even after you find it DoEvents Wend