Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Events are designated in the Object Dictionary by a lightening icon.
Is there a way to tell if an Event has fired? Example. Check the "Microsoft Internet Controls" reference library and check out the WebBrowser object - it has an event called DownloadComplete. So if I have: Set IE = CreateObject("InternetExplorer.Application") ' Same as Set IE = new WebBrowser() IE.Visible = True IE.navigate "http://www.mysite.com" Can I see if DowloadComplete fired? Can I attach code that executes when DownloadComplete fires? BTW, I see there is a Busy property which can be used to see when the download is complete - but I'd still like to learn about capturing events. Thanks. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You can declare an object variable "With Events" - this allows you to attach
to the object's events. Yim wrote in message ... Events are designated in the Object Dictionary by a lightening icon. Is there a way to tell if an Event has fired? Example. Check the "Microsoft Internet Controls" reference library and check out the WebBrowser object - it has an event called DownloadComplete. So if I have: Set IE = CreateObject("InternetExplorer.Application") ' Same as Set IE = new WebBrowser() IE.Visible = True IE.navigate "http://www.mysite.com" Can I see if DowloadComplete fired? Can I attach code that executes when DownloadComplete fires? BTW, I see there is a Busy property which can be used to see when the download is complete - but I'd still like to learn about capturing events. Thanks. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here's an exmaple using the BeforeNavigate2 and NavigateComplete2
events; In a class module named "clsIEEventHandler": Option Explicit Public WithEvents InternetExplorer As SHDocVw.InternetExplorer Private mboolNavIsComplete As Boolean Friend Property Get NavigationIsComplete() As Boolean NavigationIsComplete = mboolNavIsComplete End Property Private Sub Class_Terminate() Set Me.InternetExplorer = Nothing End Sub Private Sub InternetExplorer_BeforeNavigate2(ByVal pDisp As Object, _ ByRef URL As Variant, ByRef Flags As Variant, _ ByRef TargetFrameName As Variant, ByRef PostData As Variant, _ ByRef Headers As Variant, ByRef Cancel As Boolean) 'Fires before navigation mboolNavIsComplete = False End Sub Private Sub InternetExplorer_NavigateComplete2(ByVal pDisp As Object, _ ByRef URL As Variant) 'Fires when navigation is complete MsgBox "Navigation completed" mboolNavIsComplete = True End Sub In a standard code module: Option Explicit Sub TestIEEventHandler() Dim objIE As SHDocVw.InternetExplorer Dim objIEEvents As clsIEEventHandler Set objIE = New SHDocVw.InternetExplorer Set objIEEvents = New clsIEEventHandler Set objIEEvents.InternetExplorer = objIE With objIE .Visible = True .Navigate "http://www.DailyDoseOfExcel.com" End With 'Ensure that navigation completes before 'the event handler is destroyed Do While Not objIEEvents.NavigationIsComplete DoEvents Loop 'Destroy objects Set objIEEvents = Nothing Set objIE = Nothing End Sub As you see in the example you can use a class module to trap events of objects. As Tim says use the With Events statement.. The DowloadComplete even probably fires when a file has been downloaded (just guessing, I'm not familiar with the InternetExplorer object model. best regards Peder Schmedling On Jan 12, 6:58 am, " wrote: Events are designated in the Object Dictionary by a lightening icon. Is there a way to tell if an Event has fired? Example. Check the "Microsoft Internet Controls" reference library and check out the WebBrowser object - it has an event called DownloadComplete. So if I have: Set IE = CreateObject("InternetExplorer.Application") ' Same as Set IE = new WebBrowser() IE.Visible = True IE.navigate "http://www.mysite.com" Can I see if DowloadComplete fired? Can I attach code that executes when DownloadComplete fires? BTW, I see there is a Busy property which can be used to see when the download is complete - but I'd still like to learn about capturing events. Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Object Browser Icons | Excel Discussion (Misc queries) | |||
Object Browser does what? | Excel Programming | |||
Object Browser Help | Excel Programming | |||
Object Browser Help | Excel Programming | |||
VBA Object Browser icons key | Excel Programming |