Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1152to1156
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Offene Internet Explorer Seiten auflisten

Offene Internet Explorer Seiten auflisten
hoanto
Hallo Forum,
für eure Unterstützung wäre ich sehr dankbar.
Ich habe schon einiges gegoogelt; allerdings nicht erfolgreich.
Mein Problem:
Ich habe eine Internet Seite (Internet Explorer) offen und möchte nun mit Hilfe von VBA-Code von Excel aus auf diese offene Seite wechseln, um dort dann händisch eine Aktion durchzuführen.
Ziel ist es also, diese offene InternetSeite zu aktivieren (setfocus ?).
Vielen Dank vorab
Oliver

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Benutzer
Anzeige
AW: Offene Internet Explorer Seiten auflisten
16.04.2010 08:21:38
Tino
Hallo,
hiermit kannst Du ein bestimmtes Fenster maximieren und aktivieren.
Private Declare Function SetForegroundWindow _
  Lib "user32" ( _
  ByVal hwnd As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long

Private Declare Function GetWindowTextLength Lib "user32" _
        Alias "GetWindowTextLengthA" (ByVal hwnd As Long) _
        As Long
        
Private Declare Function GetWindowText Lib "user32" _
        Alias "GetWindowTextA" _
        (ByVal hwnd As Long, ByVal lpString As String, _
        ByVal cch As Long) As Long

Private Declare Function GetWindowLong Lib "user32" Alias _
        "GetWindowLongA" (ByVal hwnd As Long, ByVal wIndx As _
        Long) As Long
        
Private Declare Function ShowWindow Lib "user32" ( _
  ByVal hwnd As Long, _
  ByVal nCmdShow As Long) As Long
  
Private Declare Function GetWindow Lib "user32" _
       (ByVal hwnd As Long, ByVal wCmd As Long) As Long

Const GWL_STYLE& = (-16)
Const WS_VISIBLE = &H10000000
Const WS_BORDER = &H800000
Const GW_HWNDNEXT& = 2
Const GW_CHILD& = 5

Const SW_HIDE = 0 ' Versteckt das Fenster 
Const SW_MAXIMIZE = 3 ' Maximiert das Fenster 
Const SW_MINIMIZE = 6 ' Minmiert das Fenster 
Const SW_NORMAL = 1 ' Aktiviert das Fenster 
Const SW_SHOW = 5 ' Zeigt das Fenster an, auch wenn es versteckt ist 
Const SW_RESTORE = 9 ' Stellt das Fenster wieder her 
Const SW_SHOWMAXIMIZED = 3 ' Zeigt das Fenster an und Maximiert es 
Const SW_SHOWMINIMIZED = 2 ' Zeigt das Fenster an und Minimiert es 
Const SW_SHOWMINNOACTIVE = 7 ' Minimiert das Fenster aber aktiviert es nicht 
Const SW_SHOWNA = 8 ' Zeigt das Fenster an aber aktiviert es nicht 
Const SW_SHOWNOACTIVATE = 4 ' Zeigt das Fenster an ohne es zu aktivieren 
Const SW_SHOWNORMAL = 1 ' Zeigt das Fenster und aktiviert dies 

Private Function GetWindowInfo(ByVal hwnd&, STitel$, Optional booVisible As Boolean = True) As Long
Dim Result&, Style&, Title$
  
    'Darstellung des Fensters 
    Style = GetWindowLong(hwnd, GWL_STYLE)
    Style = Style And (WS_VISIBLE Or WS_BORDER)
    
    'Fensetrtitel ermitteln 
    Result = GetWindowTextLength(hwnd) + 1
    Title = Space$(Result)
    Result = GetWindowText(hwnd, Title, Result)
    Title = Left$(Title, Len(Title) - 1)
    
'prüfen ob Fenster Sichtbar 
If (Style = (WS_VISIBLE Or WS_BORDER)) Or booVisible = False Then
      If Title Like "*" & STitel & "*" Then
       GetWindowInfo = hwnd
       Exit Function
      End If
End If
GetWindowInfo = 0
End Function


Sub Fenster_Aktivieren()
Dim hwnd As Long
Dim STitel As String

'hier einen Teil vom Titel angeben 
STitel = "Internet Explorer"
'********************************* 

  hwnd = GetDesktopWindow()
  hwnd = GetWindow(hwnd, GW_CHILD)
  
  '2. Param. Fenstertitel (nur ein Teil erforderlich) 
  '3. Param. optional True nur Sichtbare, False alle 
  GetWindowInfo hwnd, STitel, True

Do While hwnd <> 0
    hwnd = GetWindow(hwnd, GW_HWNDNEXT)
   If GetWindowInfo(hwnd, STitel, True) = hwnd Then
    ShowWindow hwnd, SW_MAXIMIZE 'maximieren 
    SetForegroundWindow hwnd 'aktivieren 
   End If
Loop

End Sub
Gruß Tino
Anzeige
AW: Offene Internet Explorer Seiten auflisten
16.04.2010 10:17:47
Anton
Hallo ,
oder so:
Code:

Sub b()
  Dim objShell As Object  
  Dim IEApp As Object, win As Object  
  Dim adresse As String  
  adresse = "https://www.herber.de/forum/archiv/1152to1156/t1152139.htm" 'anpassen
  Set objShell = CreateObject("Shell.Application")  
  For Each win In objShell.Windows  
    If InStr(1, UCase(win.FullName), "IEXPLORE") > 0 Then    
      If win.Document.Location = adresse Then  
        AppActivate win.Document.Title & " - Win"
      End If  
    End If  
  Next
  Set objShell = Nothing  
End Sub  


mfg Anton
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige