I have some vba code in the ThisOutlookSession Module that causes some code
to run whenever an email arrives in the inbox.
Normally, this works fine except when I open up the VBA enviroment and do
some editing. Then the olInboxItems_ItemAdd event stop firing until I
restart outlook. Does anybody know why this is occuring and if I can stop
this behavior?
-J
Private WithEvents olInboxItems As Items
------------------------------------------------------------------
Private Sub Application_Startup()
Dim objNS As NameSpace
Set objNS = Application.GetNamespace("MAPI")
' instantiate objects declared WithEvents
Set olInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items
Set objNS = Nothing
End Sub
------------------------------------------------------------------
Private Sub olInboxItems_ItemAdd(ByVal Item As Object)
'Code that will run when a new email item arrives in the inbox
End Sub
Ken Slovak - [MVP - Outlook] - 16 Jan 2004 16:06 GMT
That is expected behavior if you are editing the VBA project code.
After you are done just place the cursor in the Application_Startup
event handler and press F5 to execute it again and your ItemAdd
handler should start working again.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginners Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
> I have some vba code in the ThisOutlookSession Module that causes some code
> to run whenever an email arrives in the inbox.
[quoted text clipped - 20 lines]
> 'Code that will run when a new email item arrives in the inbox
> End Sub