Existing Outlook session vs. new Outlook session

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!
 
D

Dmitry Streblechenko

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top