Import Holiday Calendar

Is there a way to Import a Holiday calendar into a Outlook account ..
??


Thanks ,,
LVL 4
mvalencia2003Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

omgangIT ManagerCommented:
I utilize a vbscrpt to add annual holidays to Outlook calendar.  Are you wanting something similar?
OM Gang
omgangIT ManagerCommented:
Here's a sample
OM Gang

Const olFolderCalendar = 9
Const olAppointmentItem = 1
Const olOutOfOffice = 3

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objCalendar = objNamespace.GetDefaultFolder(olFolderCalendar) 

Set objDictionary = CreateObject("Scripting.Dictionary")
objDictionary.Add "January 1, 2015", "New Year’s Day"    
objDictionary.Add "January 19, 2015", "Martin Luther King, Jr. Day"    
objDictionary.Add "February 16, 2015", "Presidents’ Day"
objDictionary.Add "May 25, 2015", "Memorial Day"
objDictionary.Add "July 3, 2015", "Independence Day"
objDictionary.Add "September 7, 2015", "Labor Day"
objDictionary.Add "October 12, 2015", "Columbus Day"
objDictionary.Add "November 11, 2015", "Veteran’s Day"
objDictionary.Add "November 26, 2015", "Thanksgiving Day"
objDictionary.Add "December 25, 2015", "Christmas Day"

colKeys = objDictionary.Keys

For Each strKey in colKeys
    dtmHolidayDate = strKey
    strHolidayName = objDictionary.Item(strKey)

    Set objHoliday = objOutlook.CreateItem(olAppointmentItem)  
    objHoliday.Subject = strHolidayName
    objHoliday.Start = dtmHolidayDate & " 9:00 AM"
    objHoliday.End = dtmHolidayDate & " 10:00 AM"
    objHoliday.AllDayEvent = True
    objHoliday.ReminderSet = False
    objHoliday.BusyStatus = olOutOfOffice
    objHoliday.Save
Next

Wscript.Echo "Holidays have been added to Outlook calendar"

Open in new window

Will SzymkowskiSenior Solution ArchitectCommented:
What format is the caledndar in? PST? All you need to do is Open Outlook and import the new calendar.

- open outlook
- click file open
- click import
- import from another program or file
- select Outlook Data FIle (PST)
- point to the path of the pst file

done

Will.
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

mvalencia2003Author Commented:
omgang,

Do I just run that from PowerShell ..??
omgangIT ManagerCommented:
Copy the code and past into Notepad.  Save as a .vbs file, e.g. 2015OutlookHolidays.vbs.  Double click to execute/run.
OM Gang
mvalencia2003Author Commented:
So I have to be logged on to the computer with that account username .. right?  If I have the calendar as a shared calendar this won't work ..

??
omgangIT ManagerCommented:
The script I posted will not update a shared calendar.  This line
Set objCalendar = objNamespace.GetDefaultFolder(olFolderCalendar)
is instantiating a folder object for the default Outlook Calendar, i.e. yours or whoever's Outlook profile you are logged on with.

Options:
1) If the shared calendar is a resource box/room/etc. that is shared by many, create an Outlook Profile for that resource box/room/etc., launch Outlook with that profile and then run the script.
2) I believe I can modify the script to update a different calendar; this will, of course, be dependent upon permissions, e.g. if you don't have permissions to add/update the calendar it will fail.
OM Gang
mvalencia2003Author Commented:
What would need to be modified to update a shared calendar?  ..
-
omgangIT ManagerCommented:
Give this a try.  It works for me on a shared calendar that I have permissions to add/update.  Instead of hard coding in a calendar name I used a folder picker dialog.
OM Gang


Const olFolderCalendar = 9
Const olAppointmentItem = 1
Const olOutOfOffice = 3


Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objCalendar = objNamespace.PickFolder

Set objDictionary = CreateObject("Scripting.Dictionary")
objDictionary.Add "January 1, 2015", "New Year’s Day"    
objDictionary.Add "January 19, 2015", "Martin Luther King, Jr. Day"    
objDictionary.Add "February 16, 2015", "Presidents’ Day"
objDictionary.Add "May 25, 2015", "Memorial Day"
objDictionary.Add "July 3, 2015", "Independence Day"
objDictionary.Add "September 7, 2015", "Labor Day"
objDictionary.Add "October 12, 2015", "Columbus Day"
objDictionary.Add "November 11, 2015", "Veteran’s Day"
objDictionary.Add "November 26, 2015", "Thanksgiving Day"
objDictionary.Add "December 25, 2015", "Christmas Day"

colKeys = objDictionary.Keys

For Each strKey in colKeys
    dtmHolidayDate = strKey
    strHolidayName = objDictionary.Item(strKey)

    Set objHoliday = objCalendar.Items.Add

    objHoliday.Subject = strHolidayName
    objHoliday.Start = dtmHolidayDate & " 9:00 AM"
    objHoliday.End = dtmHolidayDate & " 10:00 AM"
    objHoliday.AllDayEvent = True
    objHoliday.ReminderSet = False
    objHoliday.BusyStatus = olOutOfOffice
    objHoliday.Save
Next

Wscript.Echo "Holidays have been added to Outlook calendar"

Open in new window

mvalencia2003Author Commented:
ran 2nd script ,, asked to select folder .. I select Inbox on mailbox and get error =
(see attachment)


..???
C--Users-m1valencia-Downloads-2015-08-19
omgangIT ManagerCommented:
You are receiving that error because you are attempting to add calendar appointments to the Inbox folder.  You cannot select Inbox.  That's a folder for mail message items.  You must drill down and select the Calendar folder that you want to add the holidays to.  In my case, when I tested, the folder browser dialog pops us and defaults to my mailbox.  I scroll down to the additional mailbox that contains the calendar I want to update and select the Calendar folder there.

So, this brings up a point I hadn't considered previously.  The shared calendar I am updating belongs to a resource mailbox that I have loaded into my Outlook session, i.e. in the nav pane of Outlook I see both my own mailbox AND the secondary mailbox that has the shared calendar.  As you've probably noticed already, the script's folder browser dialogue only displays folders for mailboxes loaded into the current Outlook session.  It does not show Shared Calendars that you may have access to view/interact with.  I'm not sure if it's possible to programmatically interact with Shared Calendars in this way.  I will investigate.

OM Gang
omgangIT ManagerCommented:
I think I got it.  Please give this a try.
Note that you'll need to change one line of code; you need to specify the name of the Shared Calendar you are wanting to update.  You cannot specify the display name but, instead, need to specify the account name.  E.g. if the display name is 'Conference Room B' but the account name is 'confb' you'll need to specify
strSharedCalendarName = "confb"

OM Gang

Const olFolderCalendar = 9
Const olAppointmentItem = 1
Const olOutOfOffice = 3

Set objOutlook = CreateObject("Outlook.Application")

Set objNamespace = objOutlook.GetNamespace("MAPI")

strSharedCalendarName = "The Account Name for the Shared Calendar"    '<------ you need to change this
Set objRecipient = objNamespace.CreateRecipient(strSharedCalendarName)

Set objCalendar = objNamespace.GetSharedDefaultFolder(objRecipient, olFolderCalendar)

WScript.Echo objCalendar.Name

Set objDictionary = CreateObject("Scripting.Dictionary")
objDictionary.Add "January 1, 2015", "New Year’s Day"    
objDictionary.Add "January 19, 2015", "Martin Luther King, Jr. Day"    
objDictionary.Add "February 16, 2015", "Presidents’ Day"
objDictionary.Add "May 25, 2015", "Memorial Day"
objDictionary.Add "July 3, 2015", "Independence Day"
objDictionary.Add "September 7, 2015", "Labor Day"
objDictionary.Add "October 12, 2015", "Columbus Day"
objDictionary.Add "November 11, 2015", "Veteran’s Day"
objDictionary.Add "November 26, 2015", "Thanksgiving Day"
objDictionary.Add "December 25, 2015", "Christmas Day"

colKeys = objDictionary.Keys

For Each strKey in colKeys
    dtmHolidayDate = strKey
    strHolidayName = objDictionary.Item(strKey)

    Set objHoliday = objCalendar.Items.Add

    objHoliday.Subject = strHolidayName
    objHoliday.Start = dtmHolidayDate & " 9:00 AM"
    objHoliday.End = dtmHolidayDate & " 10:00 AM"
    objHoliday.AllDayEvent = True
    objHoliday.ReminderSet = False
    objHoliday.BusyStatus = olOutOfOffice
    objHoliday.Save
Next

Wscript.Echo "Holidays have been added to Outlook calendar"

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mvalencia2003Author Commented:
Thanks ,,

I can also add more items under "Set objDictionary = CreateObject("Scripting.Dictionary")"  right?


.,,
omgangIT ManagerCommented:
Below that.

objDictionary.Add "March 11, 2015", "Mom's Birthday"
objDictionary.Add "July 9, 2015", "Anniversary"   '<-----  this isn't a bad idea!
objDictionary.Add "October 12, 2015", "Wife's Birthday"   '<---- this one too!

OM Gang
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Outlook

From novice to tech pro — start learning today.