15.04.2013

Internetexplorer - bestimmte Fenster schliessen...

Frage: Ich möchte bestimmte Internetexplorer Fenster schließen. Es soll nach einem bestimmten String im Namen gesucht werden. Wie geht das?

Im ersten Code (Main) werden die Informationen zum Shell-Fenster im Direktfenster ausgegeben. Im zweiten Code (Main_1) per MsgBox. Im dritten Code (Main_2) werden alle Internetexplorer Fenster geschlossen, wenn mein Blog (Suchwort "Code") offen ist.


I want to close certain Internet Explorer window. It should be searched for a specific string in the name. How does it work?

The first code (Main), the information on the shell window will be printed in the Immediate window. The second code (Main_1) via MsgBox. The third code (Main_2) all Internet Explorer windows are closed, if my blog (search word "Code") is open.


Hier noch eine Beispieldatei / Here's a sample file:
Internetexplorer - bestimmte Fenster schliessen...[XLS 50 KB]


Option Explicit
'--------------------------------------------------------------------------
' Module    : Module1
' Procedure : Main
' Author    : Case (Ralf Stolzenburg)
' Date      : 15.04.2013
' Purpose   : Info über das Shell - Fenster - Debug.Print...
'--------------------------------------------------------------------------
Sub Main()
    Dim objWindow As Object
    Dim objShell As Object
    On Error GoTo Fin
    Set objShell = CreateObject("Shell.Application")
    For Each objWindow In objShell.Windows
        Debug.Print "LocationName: " & objWindow.LocationName
        Debug.Print "Name: " & objWindow.Name
        Debug.Print "LocationURL: " & objWindow.LocationURL
        Debug.Print "FullName: " & objWindow.FullName
        Debug.Print "Path: " & objWindow.Path
        Debug.Print vbCrLf
    Next objWindow
Fin:
    Set objShell = Nothing
    If Err.Number <> 0 Then MsgBox "Error: " & _
        Err.Number & " " & Err.Description
End Sub
'--------------------------------------------------------------------------
' Module    : Module1
' Procedure : Main_1
' Author    : Case (Ralf Stolzenburg)
' Date      : 15.04.2013
' Purpose   : Info über das Shell - Fenster - MsgBox...
'--------------------------------------------------------------------------
Sub Main_1()
    Dim objWindow As Object
    Dim objShell As Object
    Dim strTMP As String
    On Error GoTo Fin
    Set objShell = CreateObject("Shell.Application")
    For Each objWindow In objShell.Windows
        strTMP = strTMP & "LocationName: " & objWindow.LocationName
        strTMP = strTMP & vbCrLf
        strTMP = strTMP & "Name: " & objWindow.Name
        strTMP = strTMP & vbCrLf
        strTMP = strTMP & "LocationURL: " & objWindow.LocationURL
        strTMP = strTMP & vbCrLf
        strTMP = strTMP & "FullName: " & objWindow.FullName
        strTMP = strTMP & vbCrLf
        strTMP = strTMP & "Path: " & objWindow.Path
        strTMP = strTMP & vbCrLf & vbCrLf
    Next objWindow
    If strTMP <> "" Then
        MsgBox strTMP
    Else
        MsgBox "Shell - no associated window open!"
    End If
Fin:
    Set objShell = Nothing
    If Err.Number <> 0 Then MsgBox "Error: " & _
        Err.Number & " " & Err.Description
End Sub
'--------------------------------------------------------------------------
' Module    : Module1
' Procedure : Main_2
' Author    : Case (Ralf Stolzenburg)
' Date      : 15.04.2013
' Purpose   : Bestimmtes Internet Explorer Fenster (Name) schliessen...
'--------------------------------------------------------------------------
Sub Main_2()
    Dim objWindow As Object
    Dim objShell As Object
    On Error GoTo Fin
    Set objShell = CreateObject("Shell.Application")
    For Each objWindow In objShell.Windows
        If objWindow.LocationName Like "*" & "Code" & "*" Then objWindow.Quit
    Next objWindow
Fin:
    Set objShell = Nothing
    If Err.Number <> 0 Then MsgBox "Error: " & _
        Err.Number & " " & Err.Description
End Sub

Formeln auf einer UserForm in einer TextBox darstellen...

Formeln auf einer UserForm in einer TextBox anzeigen. Z. B. "Formula", "FormulaLocal"... und wie muss die Formel in VBA ...