Hi,
How can i close IE using Caption Name using VBA.
Like "Title - Windows Internet Explorer"
Hi,
How can i close IE using Caption Name using VBA.
Like "Title - Windows Internet Explorer"
Hi,
Here's one way using Word.Applications' task object.
[VBA]Public Sub CloseIEWindow()
Dim winWord As Object
Dim boolYes As Boolean
Dim Task As Object
'Check if already a word instance is running
On Error Resume Next
Set winWord = GetObject(, "Word.Application")
On Error GoTo 0
'If no then create one instance for running this code
If winWord Is Nothing Then
Set winWord = CreateObject("Word.Application")
winWord.Visible = False
boolYes = True
End If
'Loop through tasks and then close the one which has desired caption
For Each Task In winWord.Tasks
If InStr(Task.Name, "Windows Internet Explorer") > 0 Then
Task.Close
End If
Next Task
'If it was word instance which we created then close it.
If boolYes Then winWord.Quit
End Sub
[/VBA]
If you do not want to use word route then there are some api's which can be used like in this thread:
http://www.vbaexpress.com/forum/showthread.php?t=43576
Regards,
--------------------------------------------------------------------------------------------------------
Shrivallabha
--------------------------------------------------------------------------------------------------------
Using Excel 2016 in Home / 2010 in Office
--------------------------------------------------------------------------------------------------------