2 枚举ShellWindows中的窗口,要关闭的时候调用quit方法即可:
Option Explicit
'需要引用 Microsoft Internet Controls
Dim mShellWindows As New ShellWindows
Private Sub Command1_Click()
Dim b As InternetExplorer
For Each b In mShellWindows
If b.FullName = VBA.Environ$("windir") & "\explorer.exe" Then
Debug.Print b.LocationName
End If
Next
End Sub
Private Sub Command2_Click()
'关闭所有符合你要求的窗口
Dim b As InternetExplorer
For Each b In mShellWindows
If b.FullName = VBA.Environ$("windir") & "\explorer.exe" Then
b.Quit
End If
Next
End Sub