Article ID: 186471
Article Last Modified on 11/23/2006
Dim ol As Object
Dim olns As Object
Dim oCalendar As Object
Dim oAppt As Object
Dim oViewCmdBar As Object
Dim oItem As Object
Dim nItem As Integer
Sub ChangeCalendarView()
' Create Outlook Application object.
Set ol = CreateObject("Outlook.Application")
Set olns = ol.GetNameSpace("MAPI")
' Retrieve the Calendar folder.
Set oCalendar = olns.GetDefaultFolder(olFolderCalendar)
' You can retrieve your specific appointment differently.
' This is just to get the first item, so we can see the calendar
' displayed for that day.
Set oAppt = oCalendar.Items(1)
' Retrieve the View menu.
Set oViewCmdBar = oAppt.GetInspector.CommandBars.Item("View")
' Locate the Calendar control on the View menu.
nMenuItem = 1
Set oMenuItem = oViewCmdBar.Controls(nMenuItem)
Do While Not oMenuItem.Caption = "Ca&lendar..."
nMenuItem = nMenuItem + 1
Set oMenuItem = oViewCmdBar.Controls(nMenuItem)
Loop
' Display the appointment. This must be done in order for the
' calendar to be displayed on the next statement.
oAppt.GetInspector.Display
' Execute the Calendar command on the View menu.
' This is the command that displays the calendar.
oMenuItem.Execute
End Sub
180826 OL98: Resources for Custom Forms and Programming
182349 OL98: Questions About Custom Forms and Outlook Solutions
Additional query words: OutSol OutSol98 vba vbscript kbmacro
Keywords: kbhowto kbprogramming KB186471