IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Voir le flux RSS

EXCEL VB et INTERNET

Bonjour à tous,

J'ai un projet qui me pose quelques problèmes au niveau de la programmation sous VBA EXCEL : à partir d'Excel, je dois récupérer des infos d'un site, mais là où çà se complique c'est que les utilisateurs de ce dit site, sont sur Internet Explorer 11 ou Internet Edge ou Chrome ou Firefox.

Je voudrais savoir dans un 1er temps quel navigateur les utilisateurs utilisent et dans un 2nd temps comment récupérer le contenu de la page web en cours, pas la 1ère page ouverte mais celle en cours.

Si quelqu'un a des idées, cela m'intéresse, car pour l'instant je bloque...

Voici les lignes de commandes adaptées à mes besoins permettant de lire les infos d'une page web sous IE11 :


Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetForegroundWindow Lib "user32" () As Long

Sub GetURL()
On Error GoTo sortie
Dim sw As SHDocVw.ShellWindows
Dim objIE As SHDocVw.InternetExplorer
Dim topHwnd As Long, nextHwnd As Long
Dim sURL As String, hwnds As String
Set sw = New SHDocVw.ShellWindows
hwnds = "|"
If sw.Count > 1 Then
For Each objIE In sw
hwnds = hwnds & objIE.hwnd & "|"
Next
nextHwnd = GetForegroundWindow
Do While nextHwnd > 0
nextHwnd = GetWindow(nextHwnd, 2&)
If InStr(hwnds, "|" & nextHwnd & "|") > 0 Then
topHwnd = nextHwnd
Exit Do
End If
Loop
For Each objIE In sw
If objIE.hwnd = topHwnd Then
sURL = objIE.LocationURL
MsgBox sURL
Exit For
End If
Next
Else
For Each objIE In sw
sURL = objIE.LocationURL
Next
End If
Debug.Print sURL
Set sw = Nothing: Set objIE = Nothing
...
Sortie: End
End Sub


Merci à la communauté

SUPERJOE1957 n'a aucun billet à afficher.