Solved

Make calendar event private based on category

Posted on 2010-09-16
8
486 Views
Last Modified: 2014-11-12
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
Comment
Question by:cobianna
  • 5
  • 3
8 Comments
 
LVL 76

Expert Comment

by:David Lee
Comment Utility
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
 

Author Comment

by:cobianna
Comment Utility
Hi BlueDevilFan!

I'm absolutely interested in the code route.  
0
 

Author Comment

by:cobianna
Comment Utility
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
 
LVL 76

Expert Comment

by:David Lee
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 76

Expert Comment

by:David Lee
Comment Utility
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
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
Comment Utility
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
 

Author Closing Comment

by:cobianna
Comment Utility
Thanks for your help.  Worked great.
0
 
LVL 76

Expert Comment

by:David Lee
Comment Utility
You're welcome.  Glad I could help.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Cannot expand the folder in Outlook 6 21
Add a SafeSender to Exchange 6 22
outlook 2013 3 24
Email subject no showing 2 13
If your app took Google’s lash recently, here are the 5 most likely reasons.
Create high volume marketing opportunities using email signatures with these top 10 DOs and DON'Ts of email signature marketing.
This Micro Tutorial demonstrates the importance of annotations in Google Analytics and how they should be used to document changes made to a site, Google updates (Ex: Panda & Penguin), marketing campaigns, and any other events that might have contri…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now