Catching ModuleSwitch events after "open in new window"

Status
Not open for further replies.

Unlisted Unlisted

New Member
Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
I have VBA running that will automatically trigger a specific action (such as a message box) if one switches to the "mail" module by clicking the envelope icon on the lower left-hand corner of Outlook. I've pasted my code below and it works fine when I initially open a single Outlook window.

However, if I right click anywhere in Outlook that provides the "open in new window" context menu item and click it to open a new window, switching to the mail module does not generate the event in the new window ( it still works in the original Outlook window). My guess is that the Application.ActiveExplorer.NavigationPane that I reference initially works only with the original Outlook window. I'm not sure how to make it reference any new window as well and welcome thoughts from the folks on the forum.

Here is the code I have that works on the single Outlook window:

'This variable and the Application_Startup and Objpane_moduleswitch functions ensure that when you switch to the mail module, the unifiedinbox function is called
Dim WithEvents objPane As NavigationPane

' Get the NavigationPane object for the currently displayed Explorer object.
Private Sub Application_Startup()
Set objPane = Application.ActiveExplorer.NavigationPane
End Sub

' Check if the currently selected navigation module has changed to mail and if so run unified inbox sub.
Private Sub objPane_ModuleSwitch(ByVal CurrentModule As NavigationModule)
'Dim objModule As CalendarModule
If CurrentModule.NavigationModuleType = olModuleMail Then
MsgBox "Switched to mail module"
End If
End Sub
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
This is a question for @Michael Bauer. My logic says it should work, because the new window is the currently active activeexplorer, but it's probably also doing something with the window's index # and I have no idea how to work around it.
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
ActiveExplorer always points to the active explorer. However, if a new explorer is opened, it´s a new reference while the one stored in your variable still points to the first object.

You need to keep a ref on each opened explorer, which requires to add a class module to your project. This sample shows how to do that for inspectors:
Inspector Wrapper: Receive Events of Multiple Emails - VBOffice
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
oliv- property "is printed" or catching print events Outlook VBA and Custom Forms 2
oliv- Best practice for catching mailitem.events Outlook VBA and Custom Forms 0
J Outlook 2010 Changing events in Outlook calendar via opening file, importing CSV Using Outlook 0
P OWA Settings->Calendar->Events from Email; Setting changes do not hold Using Outlook 1
J Outlook Office 365 Win 10 how do I control background colors of events? Using Outlook 1
G Outlook VBA and Google Calendar ("Events") Outlook VBA and Custom Forms 1
N Using email notification to update calendar events? Outlook VBA and Custom Forms 4
P Outlook custom fields "events" Using Outlook 0
T Categorizing different colors for a series of events Using Outlook 0
P Outlook 2013 Calendar events not appear on Outlook.com Calendar Using Outlook.com accounts in Outlook 6
V iCloud not syncing categorized calendar events Using Outlook 7
W All Events Disappear from Calendar Display Using Outlook 30
I Multiple events in single request Using Outlook 6
T Events Not Showing In Outlook Today Using Outlook 3
J Calendar view for future events only? Using Outlook 3
G Hiding All Day Events Using Outlook 1
microsvc Populating everyone's calendar with campus events Exchange Server Administration 1
Dave Godbey Sending Categories on Calendar Events Using Outlook 1
C Problem accessing events for folder "username" Server Threw Exception Calendar Printing Assistant 1
S Syncing Past events from Outlook 2013 to Outlook.com Using Outlook.com accounts in Outlook 6
R How to turn OFF the Reminders for shared calendar events but not off personal Using Outlook 1
F Printing all day events only Calendar Printing Assistant 3
E Outlook 2013 , iCloud linked calendar, events one hour ahead for about a month Using Outlook 5
B Timed events created in iPhone auto-change to All Day events in Outlook 2010 Using Outlook 2
H Events in Calendar not Bold Using Outlook 1
R [VBA] complicated(?) outlook events - need help with code Using Outlook 15
S Outlook - Reset the number of day-events Using Outlook 0
B Series of calendar events? Or Tasks? Using Outlook 1
D All New Appointments are All Day Events Using Outlook 1
P Printing calendar (work week) with numerous (i.e. >7) all day events... Calendar Printing Assistant 3
A Outlook CPAO - Printing Monthly calendar with only all day events or catergory Calendar Printing Assistant 2
S Full-day events Using Outlook 1
T Changing default reminder time for all day events - additional help needed Using Outlook 1
A Share recurrent events with others Using Outlook 2
O pasting text in body of calendar events Using Outlook 5
S Copy Events to Second Calendar or Sync Only "Busy" Events Using Outlook 5
K Private Calendar events Using Outlook 3
N How can i hsve appointments and events to not display start or finish times Using Outlook 2
T Birthday events in Calendar Using Outlook 4
M Outlook does not bold calendar dates when events are scheduled for those dates. Using Outlook 1
K Mailbox Calendar Events Randomly Change - Exch2007 Exchange Server Administration 2
C Can Outlook events be synchronously refresh to the onenote link? Using Outlook 1
F No reminders for recurring events Using Outlook 5
P Trying to use ICS file to update events in Outlook Using Outlook 2
M Need help w/ Calendar Events not appearing in Outlook 2010 Using Outlook 1
M Calendar Events Not Showing in Outlook 2010 Using Outlook 1
I Making public calendar default for generated events Using Outlook 1
B Unable to update Mailbox SD in the DS. Mailbox Guid: Events occurring every 30mins. GUID doesn't exi Exchange Server Administration 6
C Calendar events not showing up in "upcoming events" on rightside of Outlook Using Outlook 1
J Outlook 2010 losing connection to Exchange 2010 server when sending and opening calendar events Using Outlook 2
Similar threads


















































Top