Application Startup

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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?
 
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?
 
Back
Top