1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| 'Ouvrir au préalable http://www.google.fr/ dans une session IE
Private Sub Form_Load()
Dim objIE As Object, objDoc As Object ' HTMLDocument
Set objIE = EnumShellWindows("Google")
If TypeName(objIE) <> "Nothing" Then
Set objDoc = objIE.document
objDoc.url = "http://msdn2.microsoft.com/en-us/library/ms630310.aspx"
Set objDoc = Nothing
End If
Set objIE = Nothing
End Sub
Private Function EnumShellWindows(CaptionFind As String) As Object
Dim WB As Object, c As Object, i As Long
Set WB = CreateObject("Shell.Application").Windows
For Each c In WB
Select Case TypeName(c.document)
Case "IShellFolderViewDual2" ' Dossier '
Case "HTMLDocument" 'Navigateur Web (IE) '
If c.LocationName = CaptionFind Then Set EnumShellWindows = c
Case Else ' ? '
End Select
i = i + 1
Debug.Print " FENETRE " & i
Debug.Print String(50, "-")
Debug.Print , "Titre : ", c.LocationName
Debug.Print , "Adresse :", c.LocationURL
Debug.Print , "Statut : ", c.StatusText
Debug.Print , "Handle : ", c.hWnd
Debug.Print String(50, "=")
Next
Set WB = Nothing
End Function |
Partager