none
VBA to change color of Appointments/Meetings in Calendar RRS feed

  • Question

  • I would like to programatically (VBA) change the colors of meetings in the Calendar view to identify meetings which I have created thru VBA.  Right now, I have them colored by assigning them a category.  I have been looking at Conditional Formating, but have not done this through VBA yet.  What is the best way to change the colors of specific meetings?

    If using conditional formatting, all the examples I saw always start with 1)Check if in Calendar view, and if so, 2) get the view object, then 3) apply the conditional formatting.  Can I do it if the Calender view is not the current view?

    What is the best way to change the colors of meetings?

    Thursday, February 20, 2014 11:33 PM

Answers

  • Hello,

    To customize the view in Outlook you need to obtain a View object by using the CurrentView property of the Explorer object (or a Folder in our case). For example:

    Sub TestFolderCurrentView()  
     Dim nsp As Outlook.NameSpace  
     Dim mpFolder As Outlook.Folder  
     Dim vw As Outlook.View  
     Dim strView As String  
     
     Set nsp = Application.Session  
     Set mpFolder = nsp.GetDefaultFolder(olFolderCalendar)  
     ' Save a reference to the current view  
     Set vw = mpFolder.CurrentView  
     MsgBox "The Current View is: " & vw.Name  
    End Sub
    

    You can find a sample code of conditional formatting MSDN, see the Filter method of the AutoFormatRule class.

    • Marked as answer by Prostar 209 Wednesday, February 26, 2014 8:33 PM
    Friday, February 21, 2014 9:51 AM