Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add event handler to an object? 3

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
How do I add an event handler to an object in MS Access VBA?

I have
Code:
    Dim objFolder As Object
    Set objFolder = oApp.GetNamespace("MAPI").GetDefaultFolder(olFolderSentItems)
    AddHandler objFolder.ItemAdd


It won't compile because it appears AddHandler isn't VBA.

However, I seem unable to dimension the objFolder object 'WithEvents' ?

How do I add the event handler for the 'ItemAdd' event on the 'Sent Items' MAPI folder object objFolder?

Thanks,
1DMF

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Free Dance Music Downloads
 
I remember my suggestion of late binding to avoid version issues.
But now you want to trap automation events ...
 
Hey, don't take that comment the wrong way! I'm very grateful for your support in 'un-binding' my apps, which is why I don't want to go back!

Have another star - though it seems you don't need any more, as once again you are Tek-Tips MVP!

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Free Dance Music Downloads
 
strongm said:
You could always create an ActiveX library that only contains a single object - a proxie that only implements the eventhandler. It can early bind, and you can early bid to it without impacting the late binding to Outlook
Any chance you are willing to provide some code, more details, or a reference to what you are suggesting? I am somewhat skeptical.
 
Unfortunately I'm currently nowhere near a machine with the necessary resources to test this out, and won't be until the New Year. However, I can see absolutely nothing wrong with the principle.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top