A
Angus
Hi all
I'm a beginner in VBA outlook programming, so please be patient with me..
I am trying to run some code when outlook closes. My code need to access
some outlook inferface objects (menubar, buttons etc).
As far as I understand, if I put the code in the application_quit sub I
obtain an error, as my object variables are out of scope. So, I declared an
explorer object and I am trying to handle it with the explorer_close sub.
But the explorer.close event is not fired: why? It seems to me that the
myExplorer object is already set to nothing, and so the event cannot be
fired? I suppose so because if I open another explorer window and then close
the first one, the messagebox function DOES work!
Here's the code, all from the ThisOutlookSession module:
------------------------------------------
Dim WithEvents myExplorer As Outlook.Explorer
Private Sub Application_Quit()
Set myExplorer = Nothing
End Sub
Private Sub Application_Startup()
Set myExplorer = Application.Explorers.Item(1)
End Sub
Private Sub myExplorer_Close()
MsgBox "Closing..."
End Sub
---------------------------------------------
If I open and then close outlook, nothing happens
If I open outlook, right-click a folder and choose "open in another window"
and then close the first outlook window, then the message "Closing..." pops
up, and the first outlook window closes.
Please help me, any suggestion would be really appreciated
Thank you so much
Angus73
---Outlook 2003, XP PRO SP3---
I'm a beginner in VBA outlook programming, so please be patient with me..
I am trying to run some code when outlook closes. My code need to access
some outlook inferface objects (menubar, buttons etc).
As far as I understand, if I put the code in the application_quit sub I
obtain an error, as my object variables are out of scope. So, I declared an
explorer object and I am trying to handle it with the explorer_close sub.
But the explorer.close event is not fired: why? It seems to me that the
myExplorer object is already set to nothing, and so the event cannot be
fired? I suppose so because if I open another explorer window and then close
the first one, the messagebox function DOES work!
Here's the code, all from the ThisOutlookSession module:
------------------------------------------
Dim WithEvents myExplorer As Outlook.Explorer
Private Sub Application_Quit()
Set myExplorer = Nothing
End Sub
Private Sub Application_Startup()
Set myExplorer = Application.Explorers.Item(1)
End Sub
Private Sub myExplorer_Close()
MsgBox "Closing..."
End Sub
---------------------------------------------
If I open and then close outlook, nothing happens
If I open outlook, right-click a folder and choose "open in another window"
and then close the first outlook window, then the message "Closing..." pops
up, and the first outlook window closes.
Please help me, any suggestion would be really appreciated
Thank you so much
Angus73
---Outlook 2003, XP PRO SP3---