Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Selection d'une fenêtre

2 réponses
Avatar
Infogroup
Bonjour à tous,

depuis une feuil " Feuil1 ", je cherche à activer la fenêtre d'Internet
Explorer qui elle est déjà ouverte.

Pouvez-vous m'indiquer quelle est l'instruction VBA à utiliser ?

A noter également qu'il peut y avoir d'autres fenêtre ouvertes comme Word ou
d'autres.

Merci pour vous réponses

CDL

Infogroup

2 réponses

Avatar
MichDenis
En supposant que tu as une instance d'internet explorer d'ouvert :

Voici un bout de code de Michel Perron :

'Déclaration des API dans le haut d'un module standard :
Option Explicit
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetWindow& Lib "user32" (ByVal hwnd&, ByVal wCmd&)
Private Declare Function GetWindowLong& Lib "user32" _
Alias "GetWindowLongA" (ByVal hwnd&, ByVal nIndex&)
Private Declare Function GetWindowText& Lib "user32" Alias _
"GetWindowTextA" (ByVal hwnd&, ByVal lpString$, ByVal aint&)
Private Const mconMAXLEN = 255
'----------------------------------
Sub Activer_Fenêtre_Internet_Explorer()
Dim hwnd&, Style&, Title$, i&
hwnd = GetWindow(GetDesktopWindow(), 5)
Do While hwnd
Title = GetCaption(hwnd)
If Len(Title) Then
' Enum visible windows only
If GetWindowLong(hwnd, -16) And &H10000000 Then
If InStr(1, Title, "Internet explorer", 1) Then
AppActivate Title
Exit Sub
End If
End If
End If
hwnd = GetWindow(hwnd, 2)
Loop
End Sub
'----------------------------------
Private Function GetCaption(hwnd&) As String
Dim i%, Buffer$: Buffer = String$(254, 0)
i = GetWindowText(hwnd, Buffer, 255)
If i Then GetCaption = Left$(Buffer, i)
End Function
'----------------------------------




"Infogroup" a écrit dans le message de groupe de discussion :
#
Bonjour à tous,

depuis une feuil " Feuil1 ", je cherche à activer la fenêtre d'Internet
Explorer qui elle est déjà ouverte.

Pouvez-vous m'indiquer quelle est l'instruction VBA à utiliser ?

A noter également qu'il peut y avoir d'autres fenêtre ouvertes comme Word ou
d'autres.

Merci pour vous réponses

CDL

Infogroup
Avatar
Infogroup
Merci infiniment à toi MichDenis, c'est absolument nickel

Cdl

Infogroup


"MichDenis" a écrit dans le message de
news:
En supposant que tu as une instance d'internet explorer d'ouvert :

Voici un bout de code de Michel Perron :

'Déclaration des API dans le haut d'un module standard :
Option Explicit
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetWindow& Lib "user32" (ByVal hwnd&, ByVal
wCmd&)
Private Declare Function GetWindowLong& Lib "user32" _
Alias "GetWindowLongA" (ByVal hwnd&, ByVal nIndex&)
Private Declare Function GetWindowText& Lib "user32" Alias _
"GetWindowTextA" (ByVal hwnd&, ByVal lpString$, ByVal aint&)
Private Const mconMAXLEN = 255
'----------------------------------
Sub Activer_Fenêtre_Internet_Explorer()
Dim hwnd&, Style&, Title$, i&
hwnd = GetWindow(GetDesktopWindow(), 5)
Do While hwnd
Title = GetCaption(hwnd)
If Len(Title) Then
' Enum visible windows only
If GetWindowLong(hwnd, -16) And &H10000000 Then
If InStr(1, Title, "Internet explorer", 1) Then
AppActivate Title
Exit Sub
End If
End If
End If
hwnd = GetWindow(hwnd, 2)
Loop
End Sub
'----------------------------------
Private Function GetCaption(hwnd&) As String
Dim i%, Buffer$: Buffer = String$(254, 0)
i = GetWindowText(hwnd, Buffer, 255)
If i Then GetCaption = Left$(Buffer, i)
End Function
'----------------------------------




"Infogroup" a écrit dans le message de groupe de
discussion :
#
Bonjour à tous,

depuis une feuil " Feuil1 ", je cherche à activer la fenêtre d'Internet
Explorer qui elle est déjà ouverte.

Pouvez-vous m'indiquer quelle est l'instruction VBA à utiliser ?

A noter également qu'il peut y avoir d'autres fenêtre ouvertes comme Word
ou
d'autres.

Merci pour vous réponses

CDL

Infogroup