Application Startup

S

SGreville

Hello

I have some code to run at the start of Outlook to initiate the item add
event handler.
However the code in the Application_Startup does not fire.

The macro security is set to low and the application_quit procedure fires
when i exit outlook if i have opend the VBA window before closing.

I am running in Outlook 2000 SP3 through citrix server, however i have
encountered the same problem on a standard windows 2000 client.

Here is the code


Option Explicit
Private WithEvents olInboxItems As Items
Private Sub Application_Quit()
' disassociate global objects
Set olInboxItems = Nothing
MsgBox "Bye Bye", vbInformation ' this fires if the code window has been
opened before closing outlook.
End Sub
Private Sub Application_Startup()
Dim objNS As NameSpace
Set objNS = Application.GetNamespace("MAPI")
Set olInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items
Set objNS = Nothing
Application.ActiveExplorer.WindowState = olMaximized
MsgBox ("Startup") ' Just to see if the procedure is firing.
End Sub

Private Sub olInboxItems_ItemAdd(ByVal Item As Object)
' this procedure works fine once event is initialised
End Sub

Many thanks in advance
Stuart
 
E

Eric Legault [MVP - Outlook]

I can't imagine what the problem could be; your code runs fine for me in
OL2003.

Have you tried adding a Stop statement in Application_Startup to assist your
debugging?
 
S

sgreville

Yeah i have tried the stop stament and no luck there.
The weird thing is that the Quit event won't fire unless i have opened the
vba window prior to closing.

And ideas?
 

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