explorer_close not fired

Status
Not open for further replies.
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---
 
What is it that you need to do in Explorer_Close? There may be better ways

to accomplish your actual goals.

Sue Mosher

"Angus" <Angus> wrote in message

news:D02C3EAF-FAB3-4A0A-9513-145101E07EAE@microsoft.com...
> 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---
 
Hi Sue, thanks for your reply

I would need to execute a menu command: my final goal would be to

automatically delete IMAP messages marked for deletion when outlook closes.

Here's the actual code I tried to put in explorer_close (for better reading,

in my first post I replaced it with the msgbox):

-----------------------Dim myBars As CommandBars

Dim myMenuBar As CommandBar

Dim myEditMenu As CommandBarControl

Set myBars = myExplorer.CommandBars

Set myMenuBar = myBars(4)

Set myEditMenu = myMenuBar.Controls(2)

If myEditMenu.Controls(11).Caption = "Rimuo&vi messaggi eliminati" Then

'"remove items marked for deletion"

myEditMenu.Controls(11).Execute

Else

MsgBox "mA cHE sTRANO!!" ' Error message (the menu is not the one I

intended to use)

End If

Set myBars = Nothing

Set myMenuBar = Nothing

Set myEditMenu = Nothing

-----------------------Thank you very much for your help!

Andrea

"Sue Mosher [MVP]" wrote:


> What is it that you need to do in Explorer_Close? There may be better ways
> to accomplish your actual goals.

> > Sue Mosher
> > >

> "Angus" <Angus> wrote in message
> news:D02C3EAF-FAB3-4A0A-9513-145101E07EAE@microsoft.com...
> > 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---


>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
K Working with Explorer.Close event Outlook VBA and Custom Forms 3
R Quick Access view in File Explorer when saving attachments Using Outlook 0
R Sending emails via Outlook XP, from Windows 10 File Explorer Using Outlook 1
P Automate Outlook Start - No Active Explorer Object Found Using Outlook 10
K Macro Not Executing then send email from Explorer Outlook VBA and Custom Forms 3
I Windows 10 - .msg files on disk show Explorer popup error Using Outlook 5
M Question: Is there a rule that will save email in Windows Explorer Outlook VBA and Custom Forms 3
oliv- How to select an mailitem in explorer with "show as conversation" Outlook VBA and Custom Forms 8
Michael Chiasson PST file shows 300+MB in Windows Explorer, but only 250kb in Outlook 2010 Using Outlook 1
P Was Helvetica crashing Outlook, now fix has messed up explorer Using Outlook 4
R Outlook 2007 - drag drop email to Explorer Using Outlook 1
A vb6 run time error 5 when Outlook 2007 Explorer object displayed Outlook VBA and Custom Forms 1
C Create a Ribbon for the OL2010 Explorer Outlook VBA and Custom Forms 1
E Can I hide an explorer or make an explorer modal Outlook VBA and Custom Forms 2
E Can I hide an explorer or make an explorer modal Outlook VBA and Custom Forms 2
A Active explorer issue Outlook VBA and Custom Forms 15
S How to italicize the email entry in explorer window Outlook VBA and Custom Forms 3
T Creating toolbar in new Explorer Outlook VBA and Custom Forms 3
S Strange Behaviour of Explorer Object. Outlook VBA and Custom Forms 1
T Is Explorer.FolderSwitch the best event for hiding commandbarbutton? Outlook VBA and Custom Forms 5
R destroying Explorer object pointers on shutdown Outlook VBA and Custom Forms 2
U Not able to delete Add-in button from multiple Outlook Explorer Outlook VBA and Custom Forms 1
macdotcom Outlook 365 Outlook folder export to PST archival tool - close, but need a nudge Outlook VBA and Custom Forms 2
S Why do I have to close and reopen Outlook for macros to work? Outlook VBA and Custom Forms 2
O Outlook 365 - Toolbar - Close all items - missing? Using Outlook 3
Diane Poremsky How to Compact the Data File When you Close Outlook Using Outlook 0
Diane Poremsky Close a Meeting When the Room is Full Using Outlook 0
L Gmail POP, Android IMAP, Outlook 2013 setup close Using Outlook 5
D Close Oulook after sending emails via vba without outbox getting stuck. Outlook VBA and Custom Forms 1
D help with Item/Inspector close event Outlook VBA and Custom Forms 1
D RUN SCRIPT WHEN OUTLOOK IS CLOSE Outlook VBA and Custom Forms 1
F Automatically close email after selecting mark unread Using Outlook 1
S Pop up reminder while i close outlook Outlook VBA and Custom Forms 5
Y (Shared Folder) Using the preview pane to open and close a fax, without opening the email itself Using Outlook 1
C Open/Close Outlook - Via Excel VBA Using Outlook 2
J OL wont close after VB app runs Using Outlook 17
Q Looking for Outlook 2010 Close Event Id Exchange Server Administration 1
R Can't close Personal Folders after switching to Exchange 2010 Using Outlook 2
R Outlook and google calendar stuck if I close outlook Using Outlook 1
J Messages close themselves - Outlook 2007 Using Outlook 1
P Minimize button causes Outlook to close 2007 Using Outlook 1
D Cannot Close pst file Using Outlook 1
K The file c:\...\Outlook1.pst cannot be accessed because another workstation has modified it. Close a Using Outlook 2
R Outlook 2003 - Close parent form before opening child form Outlook VBA and Custom Forms 4
S Error 287 on Inspector.Close() Outlook VBA and Custom Forms 4
D Macro to Close Open Messages Outlook VBA and Custom Forms 3
E How to know if a Form.Close Event is the result of canceling Outlook VBA and Custom Forms 3
Q Why is BCM causing Outlook to close? BCM (Business Contact Manager) 2
V Move email using the Close event Outlook VBA and Custom Forms 11
R Close item Outlook VBA and Custom Forms 4

Similar threads

Back
Top