Object Events for Object you Created

S

spero

I do not know if the answer is right infront of me or that it is just not
possible! I am using Accsess to create an Internet Explorer object and I want
events in the object to trigger functions in my database. Is it even possible?


So lets my db app takes a user to the DMV to download a file, and on download
complete, I close the object and open the file. Here are the IE events,
problem is that I just do not know how to trigger them

Coding if I was only smart enough:
sub anything click:
Set Newsite = CreateObject("InternetExplorer.application")
Newsite.Visible = True
Newsite.StatusBar = False
Newsite.AddressBar = False
Newsite.Navigate http://www.dmv.com
end sub

Some where in my modules:

Object = Newsite
Private Sub object_DocumentComplete( _
ByVal pDisp As Object, _
ByVal URL As Variant)

Do somthing here

end sub



Link IE API (very good source);
http://msdn.microsoft.com/en-us/library/aa752084(VS.85).aspx
 
G

Graham Mandeno

Hi Spero

Are you declaring you Newsite object WithEvents?

Dim WithEvents Newsite As InternetExplorer
 
S

spero via AccessMonster.com

Graham:

I am not becuase I am creating the Object. Obect name is :newsite' and I am
just looking to catch the fire on quit so the app knows that IE has been shut
down, so I want the close of the object to be like a button click or any
other event driven item in VBA.
 
G

Graham Mandeno

I'm sorry, I didn't explain clearly. To have the events of the external
object delivered to your application, you MUST declare it WithEvents.
 
G

Graham Mandeno

Hi Spero

That's the point. You don't declare it as an Object, because an Object has
no object model at compile time and therefore cannot have pre-defined
events. You must declare it explicitly as the required object type - in
this case InternetExplorer.

Also, to have events delivered, you must use the WithEvents keyword in the
declaration:

Dim WithEvents Newsite As InternetExplorer

This should be in the declarations section of your class module or form
module. Note that you cannot declare WithEvents objects in a standard
module,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top