Existing Outlook session vs. new Outlook session

  • Thread starter Thread starter Doug Dixon
  • Start date Start date
D

Doug Dixon

I am a newbie, and all I am trying to do is open the 'My
Contacts' folder in my existing Outlook session. Instead,
this code keeps opening a new session of Outlook to
display the folder. What am I doing wrong?

Set olns = Outlook.Application.GetNamespace("MAPI")
Set MyFolder1 = olns.Folders("Public Folders")
Set MyFolder2 = MyFolder1.Folders("All Public Folders")
Set MyFolder3 = MyFolder2.Folders("My Contacts")
MyFolder3.Display

Thanks!
 
Use something like the following instead:

if Application.Explorers.Count = 0 Then
MyFolder3.Display
else
set Application.ActiveExplorer.CurrentFolder = MyFolder3
endif

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Back
Top