View Full Version : Code in IE's Close event
dansam
10-06-2007, 02:52 AM
Hi everyone, :hi:
I use this code to load a new web-browser:
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = true
Now I want to show a message when it closes. Like some code in on_Exit event we apply in a web-browser event which is on a userform but this is not on a form but it is dynamically created . So any ideas? :think:
Thanks, :thumb
Dan
Bob Phillips
10-06-2007, 03:39 AM
Can you monitor it continually?
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
Do
ieName = ""
On Error Resume Next
ieName = ie.Name
On Error GoTo 0
Loop Until ieName = ""
dansam
10-06-2007, 05:27 AM
Hi xld,
What will that code do ? For example if I nevigate the browser to yahoo.com then I click on close button & then what ?
Thanks,
Dan
Bob Phillips
10-06-2007, 05:57 AM
That code will loop aroiund until IE is closed. It then cariies on.
Ivan F Moala
10-06-2007, 03:30 PM
you will need to create a Class module and instatiate the ie control, then use the controls event
eg
Set Refrence to [Microsoft internet controls] = shdocvw.dll
create Class module named clsIE
Option Explicit
'// Class Name clsIE
Public WithEvents IE As InternetExplorer
Private Sub Class_Initialize()
Set IE = New InternetExplorer
End Sub
Private Sub Class_Terminate()
Set IE = Nothing
End Sub
Private Sub Ie_OnQuit()
MsgBox "Closed now"
End Sub
Then STD Module
Option Explicit
Dim objApp As clsIE
Sub Tester()
'// Ivan F Moala
Set objApp = New clsIE
With objApp
.IE.Visible = True
.IE.Navigate ("http://vbaexpress.com/forum/showthread.php?t=15381")
End With
End Sub
dansam
10-07-2007, 12:55 AM
Hi Ivan,
Your code worked fine. Thanks for quick help.:clap:
Dan
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.