Add below VBA references
VBA UI Automation - Close All IE windows |
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _ |
ByVal lpClassName As String, _ |
ByVal lpWindowName As String) As Long |
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _ |
ByVal HWnd As Long, _ |
ByVal wMsg As Long, _ |
ByVal wParam As Long, _ |
lParam As Any) As Long |
Public Const WM_CLOSE As Long = &H10 |
Public Const IE_WINDOW_CLASS = "IEFrame" |
Sub CloseAllInternetExplorer() |
Dim HWnd As Long |
HWnd = FindWindow(IE_WINDOW_CLASS, vbNullString) |
Do Until HWnd = 0 |
SendMessage HWnd, WM_CLOSE, 0&, 0& |
HWnd = FindWindow(IE_WINDOW_CLASS, vbNullString) |
Loop |
End Sub |
Comments
Post a Comment