Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 236
Default Getting Information about Events Seen In the Object Browser

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Getting Information about Events Seen In the Object Browser

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Getting Information about Events Seen In the Object Browser

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Object Browser Icons dhstein Excel Discussion (Misc queries) 2 June 19th 09 12:15 AM
Object Browser does what? davegb Excel Programming 6 June 27th 05 06:12 PM
Object Browser Help [email protected] Excel Programming 0 January 6th 05 08:19 PM
Object Browser Help [email protected] Excel Programming 0 January 6th 05 08:18 PM
VBA Object Browser icons key dannyraw Excel Programming 1 October 14th 04 05:08 PM


All times are GMT +1. The time now is 01:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"