Displaying Calendar Explorer

D

Dan

Hi,
Still on my quest to time certain things in Outlook.
I'm now trying to get the time it takes to go from displaying the Inbox to
displaying the calendar.
I have this code here but unfortunately it opens another instance of
Outlook, instead of causing the current instance (which I have opened
earlier on in my code) to display the calendar.

MyStartTime = Now
Set objFolderCalendar = objNamespace.GetDefaultFolder(olFolderCalendar)
Set expCalendar = objFolderCalendar.GetExplorer
expCalendar.Activate
TimeToDisplayCalendar = DateDiff("s",MystartTime,Now)

Is this another case of you can't manipulate the GUI through code?

Thanks,
Dan
 
K

Ken Slovak - [MVP - Outlook]

Use ActiveExplorer and set the CurrentFolder property to the folder you want
to switch to, after getting that folder as a MAPIFolder object. Using
GetExplorer will open a new Explorer and not reuse the current one.
 
D

Dan

Hi Ken,
Thanks.
I've tried this but it errors out... is this what you meant?

MyStartTime = Now
Set objFolderCalendar = objNamespace.GetDefaultFolder(olFolderCalendar)
Set expActive = objOutlook.ActiveExplorer
expActive.CurrentFolder = objFolderCalendar <---- error here
TimeToDisplayCalendar = DateDiff("s",MystartTime,Now)

the actual error was: The operation failed.
 
D

Dan

Sorry, my bad. Should have been
Set expActive.CurrentFolder = objFolderCalendar

Thanks, works great.

Dan
 
Top