• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 502
  • Last Modified:

Make calendar event private based on category

I sync my google calendar with my corp Outlook account.  All items that sync from my google calender come in with a category of "Family".  I would like to mark these items as private in my Outlook calendar so they can not be seen by those who I share my calendar with.  
0
cobianna
Asked:
cobianna
  • 5
  • 3
1 Solution
 
David LeeCommented:
Hi, cobianna.

Let me start by saying that I've no experience using Outlook with Google calendar.  Depending on how that sync process works it might be possible to do this automatically with a bit of code.  If that doesn't work, then it's possible to do it with a bit of code, but it won't be automatic.  You'll have to run the code manually.  Interested?
0
 
cobiannaAuthor Commented:
Hi BlueDevilFan!

I'm absolutely interested in the code route.  
0
 
cobiannaAuthor Commented:
Hi BlueDevil Fan!

I hadn't hear back from you in a while.  Just wanted to check in with you to see if you are still able to help me.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
David LeeCommented:
Hi, Cobianna.

Sorry to be so slow.  Here's the code.  It comes in two parts.  This is part #1.  

Follow these instructions to add the code to Outlook.

1.  Start Outlook
2.  Click Tools > Macro > Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects
4.  Right-click on Class Modules, select Insert > Class Module
5.  In the Properties panel click on Name and enter FamilyAppts
6.  Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook's VB Editor window
7.  Edit the code as needed.  I included comments wherever something needs to or can change
8.  Click the diskette icon on the toolbar to save the changes
9.  Close the VB Editor


Private WithEvents olkFolder As Outlook.Items

Private Sub Class_Initialize()
    Set olkFolder = Outlook.Application.Session.GetDefaultFolder(olFolderCalendar).Items
End Sub

Private Sub Class_Terminate()
    Set olkFolder = Nothing
End Sub

Private Sub olkFolder_ItemAdd(ByVal Item As Object)
    FamilyCheck Item
End Sub

Private Sub olkFolder_ItemChange(ByVal Item As Object)
    FamilyCheck Item
End Sub

Private Sub FamilyCheck(olkItem As Outlook.AppointmentItem)
    Dim arrCats As Variant, varCat As Variant
    arrCats = Split(olkItem.Categories, ",")
    For Each varCat In arrCats
        If LCase(varCat) = "family" Then
            If olkItem.Sensitivity <> olPrivate Then
                olkItem.Sensitivity = olPrivate
                olkItem.Save
            End If
            Exit For
        End If
    Next
End Sub

Open in new window

0
 
David LeeCommented:
This is part #2.

Follow these instructions to add the code to Outlook.

1.  Start Outlook
2.  Click Tools > Macro > Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects and click on ThisOutlookSession
4.  Copy the code from the Code Snippet box and paste it into the right-hand pane of
5.  Outlook's VB Editor window
6.  Edit the code as needed.  I included comment lines wherever something needs to or can change
7.  Click the diskette icon on the toolbar to save the changes
8.  Close the VB Editor
9.  Click Tools > Macro > Security
10. Set the Security Level to Medium
11. Close Outlook
12. Start Outlook
13. Outlook will display a dialog-box warning that ThisOutlookSession contains macros and asking if you want to allow them to run.  Say yes.

Dim objFamilyAppts As Object

Private Sub Application_Quit()
    Set objFamilyAppts = Nothing
End Sub

Private Sub Application_Startup()
    Set objFamilyAppts = New FamilyAppts
End Sub

Open in new window

0
 
David LeeCommented:
I'm not sure that this code will work with a Google calendar sync and since I don't use Google myself I can't test it.  The approach I've taken here is to watch the calendar for adds and changes.  When one occurs the code checks to see if the added/changed item is a member of the "Family" category.  If it is, then it sets the appointment to "private".  What I don't know is if the Google calendar sync triggers the events raised by a normal item add/change.  If it doesn't, then this won't work and I've no suggestions on how to proceed.
0
 
cobiannaAuthor Commented:
Thanks for your help.  Worked great.
0
 
David LeeCommented:
You're welcome.  Glad I could help.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now