Outlook Calendar Future Dates

  • Thread starter Thread starter Clift
  • Start date Start date
C

Clift

Need help in creating a vba/macro that will scroll the month view in Outlook
so that todays date is in the first row of the view when opened, showing only
future weeks.

Thank you in advance
Clift
 
Outlook version? For Outlook 2007 you can use CalendarView.GoToDate(), for
earlier versions of Outlook there's no way to do what you want.

CalendarView in Outlook 2007 also has other properties that allow you to set
other view options in addition to the focus date.
 
Ken,

Thank you for your suggestion. From Googling VBA code, I have found the code
that I think will do what I need .
-----------------------------
Dim oCV As Outlook.CalendarView

Set oCV = Application.ActiveExplorer.CurrentView
If oCV.CalendarViewMode = olCalendarViewMonth Then
Application.ActiveExplorer.CurrentView.GoToDate DateAdd("d", 30, Date)
End I
----------------------------------------------------------------------------------------
Can you tell me where I should put this routine so that it will fire upon
opening the calendar?

Thank you in advance,
Clift
 
I'd put the code in the ThisOutlookSession class module. Then in that module
I'd use the Application_Startup() event to also initialize an Explorer
object declared WithEvents. I'd set the Explorer to ActiveExplorer and
handle the BeforeFolderSwitch() event, which would tell you that the view is
moving to a different folder. In the initialization I'd check the
Explorer.CurrentFolder property to see what folder Outlook had started in.
Then checking that property in the event handler would let you know when the
Calendar folder was selected.
 
Ken,

I finished the code to do this, but, I was only testing it on today's date,
when I set my system date to say (8/22/2008), that date is scrolled off of
the screen showing the whole month of September. Is there a way to keep
whatever date is specified with the (CurrentView.GoToDate) to be on the first
row of the calendar monthly view.

Am also posting the code, maybe I am not using the correct objects etc...
-----------------------------------------------------------------------------------------------
Dim WithEvents m_appExplorer As Explorer

Private Sub Application_Startup()
Set m_appExplorer = Application.ActiveExplorer
End Sub

Public Sub CalendarScrollProc()
Dim ol_CurrentView As Outlook.CalendarView

On Error Resume Next

Set ol_CurrentView = Application.ActiveExplorer.CurrentView
'Only want to run if current view is "Month"
If ol_CurrentView.CalendarViewMode = olCalendarViewMonth Then
ol_CurrentView.GoToDate DateAdd("d", 30, Date)
End If

End Sub

Private Sub m_appExplorer_ViewSwitch()

On Error Resume Next
If m_appExplorer.CurrentFolder = "Calendar" Then
CalendarScrollProc
End If

End Su
-----------------------------------------------------------------------------------------------

Thanks again for your help, I appreciate it.
Clift
 
How it shows up is a matter of what date you select and how your calendar
view is set up as well as your screen size.

For example, on the laptop I tested on the dates in month view always
started by placing the first date of the specified month on the top row. In
the case of 8/22 that put the week starting on July 27 on the first row. So
I don't think you'll be able to start a row with a date like 8/22. The best
you could do would put the beginning of August on the top row..
 
Ken,

Thank you again for your help, I am going to punt on this one, hopefully in
a future version/patch this option will be added. It just makes sense (to me
anyway) that if you switch to Calendar/Monthly view, you would want to see
dates going forward.

Clift

Ken Slovak - said:
How it shows up is a matter of what date you select and how your calendar
view is set up as well as your screen size.

For example, on the laptop I tested on the dates in month view always
started by placing the first date of the specified month on the top row. In
the case of 8/22 that put the week starting on July 27 on the first row. So
I don't think you'll be able to start a row with a date like 8/22. The best
you could do would put the beginning of August on the top row..
 
Back
Top