Solved

Make calendar event private based on category

Posted on 2010-09-16
8
492 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
ID: 33696636
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
ID: 33700583
Hi BlueDevilFan!

I'm absolutely interested in the code route.  
0
 

Author Comment

by:cobianna
ID: 33720068
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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 76

Expert Comment

by:David Lee
ID: 33742183
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
 
LVL 76

Expert Comment

by:David Lee
ID: 33742201
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
ID: 33742221
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
ID: 33744955
Thanks for your help.  Worked great.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 33745270
You're welcome.  Glad I could help.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
This Micro Tutorial will demonstrate common damaging and frequent mistakes I see in most analytic audits. Most of them are campaign tagging mistakes, so this video will break it down into simple steps.
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

776 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