We can try that. I knocked up the following code to grab the IE windows, but it's not bringing in the document content. I don't have time to look any more this morning though, so hopefully you can fight with it a bit and get somewhere. If not, I'll try and loop back on it later tonight.
Code:
Sub ExplorerTest()
Dim sURL_to_Retrieve As String
Dim appIE As SHDocVw.InternetExplorer
'Check if page is already open
sURL_to_Retrieve = "http://www.excelguru.ca"
Set appIE = GetOpenIEByURL(sURL_to_Retrieve, False)
If appIE Is Nothing Then
'No IE instance open. Tell user
MsgBox "Sorry, but internet explorer isn't open." & vbNewLine & _
"Please open IE and log in to the site before" & vbNewLine & _
"running this macro.", vbInformation + vbOKOnly, "IE is not open!"
End If
'Get the HTML from the page
With appIE
'Where the heck is the document content???
.Refresh
End With
Set appIE = Nothing
End Sub
Function GetOpenIEByURL(sURL As String, Optional ByVal bExactMatch As Boolean = True) As SHDocVw.InternetExplorer
'Finds an open IE site by checking the URL
Dim objShellWindows As SHDocVw.ShellWindows
Dim lCount As Long
Set objShellWindows = New SHDocVw.ShellWindows
If bExactMatch = False Then sURL = "*" & sURL & "*"
'Ignore errors when accessing the document property
On Error Resume Next
'Loop through all open Shell-Windows
For lCount = 1 To objShellWindows.Count
'Only look at HTML documents
If TypeName(objShellWindows.Item(lCount - 1).Document) = "HTMLDocument" Then
'Check the URL
If objShellWindows.Item(lCount - 1).LocationURL Like sURL Then
'Exit the function, since we found the right URL to work with
Set GetOpenIEByURL = objShellWindows.Item(lCount - 1)
Exit Function
End If
End If
Next
End Function
Bookmarks