none
Create appointment categories in shared calendars RRS feed

  • Question

  • Hi everybody,

    I would like to create a code for every team leader that sets up appointment categories automatically to all his team member's calendars.

    Teams share calenders with their lead. I have the following code that does it for my own calender. But I don't understand how to modify it to do it in a shared calendar. The best thing would be to be able to select which shared calendars would be impacted since a team lead might have other shared calendars outside his team.

    Thanks a lot for your help

    Here is the code:

    Sub test()
    Dim objNameSpace
        Dim objCategory
        ' Obtain a NameSpace object reference
        Set objNameSpace = Application.GetNamespace("MAPI")
        'Add the Category, set its color and shortcutkey, if any
        Set objCategory = objNameSpace.Categories.Add("", OlCategoryColor.olCategoryColorDarkBlue, OlCategoryShortcutKey.olCategoryShortcutKeyNone)
      
       ' Clean up
        Set objCategory = Nothing
        Set objNameSpace = Nothing
       
     
    End Sub



    Monday, March 31, 2014 9:15 AM

Answers

  • Hello,

    The Categories property of the Namespace class from the Outlook object model represents the Master Category List (is the set of Category objects). The list applies to all users of that namespace, or Store if you use its property. So, you can modify the Categories property of the Appointment item. The owner will need to upgrade to color categories to add it to the master list.

    To access the shared calendar folder you can use the GetSharedDefaultFolder or OpenSharedFolder methods of the Namespace class. Also see the OpenSharedItemmethod which opens a shared item from a specified path or URL.

    Finally, you may find the categories in public folders - calendars forum thread helpful.

    • Marked as answer by wordaxe Monday, March 31, 2014 1:55 PM
    Monday, March 31, 2014 12:36 PM
  • Adding a category to NameSpace.Categories won't add it to the master list for the shared folder or its Store. Once GetSharedDefaultFolder() is used to get the shared folder, its Store property can be accessed and then using the Categories property of the Store would add any new categories to that store, and not just to the user's default store.

    Ken Slovak MVP - Outlook

    • Marked as answer by wordaxe Monday, March 31, 2014 1:55 PM
    Monday, March 31, 2014 1:45 PM
    Moderator

All replies

  • Hello,

    The Categories property of the Namespace class from the Outlook object model represents the Master Category List (is the set of Category objects). The list applies to all users of that namespace, or Store if you use its property. So, you can modify the Categories property of the Appointment item. The owner will need to upgrade to color categories to add it to the master list.

    To access the shared calendar folder you can use the GetSharedDefaultFolder or OpenSharedFolder methods of the Namespace class. Also see the OpenSharedItemmethod which opens a shared item from a specified path or URL.

    Finally, you may find the categories in public folders - calendars forum thread helpful.

    • Marked as answer by wordaxe Monday, March 31, 2014 1:55 PM
    Monday, March 31, 2014 12:36 PM
  • Adding a category to NameSpace.Categories won't add it to the master list for the shared folder or its Store. Once GetSharedDefaultFolder() is used to get the shared folder, its Store property can be accessed and then using the Categories property of the Store would add any new categories to that store, and not just to the user's default store.

    Ken Slovak MVP - Outlook

    • Marked as answer by wordaxe Monday, March 31, 2014 1:55 PM
    Monday, March 31, 2014 1:45 PM
    Moderator
  • Eugene and Ken thanks a lot!

    Your answers helped me to understand that VBA is not the right solution to manage multiple user's Master Category List (MCL). I have found this page: http://www.slipstick.com/tutorial/how-to-upgrade-to-color-categories/    that provides a list of tool to manage MCLs with multiple users


    • Edited by wordaxe Monday, March 31, 2014 1:55 PM
    Monday, March 31, 2014 1:50 PM