• Outlook User
  • Exchange Admin
  • Office 365
  • Outlook Developer
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
    • Common Problems
    • Outlook BCM
    • Utilities & Addins
    • Video Tutorials
    • EMO Archives
    • Outlook Updates
    • Outlook Apps
    • Forums

Save appointments to a non-default Outlook calendar folder

Slipstick Systems

› Developer › Save appointments to a non-default Outlook calendar folder

Last reviewed on October 3, 2017     11 Comments

July 27, 2012 by Diane Poremsky 11 Comments

To use this macro with a calendar in another folder (such as to move appointments to a hotmail or iCloud calendar), you need to use the function found at Working with VBA and non-default Outlook Folders. Instructions to use other calendar folders in your default data file are there also.

Replace pst-display-name with the name as seen in the folder list.
Folder paths

For a version of this macro that copies new appointments that have Show time as set to Busy to another calendar, see Copy new appointments to another calendar using VBA

To use with Contacts, use olFolderContacts instead of olFolderCalendar.

Create Tasks from Email and move to different Task folders

VBA: Move Appointments to a different calendar

To use, check your Macro security setting; it needs to be on low while testing. Press Alt+F11 to open the VBA Editor. Expand the project folder and paste this into ThisOutlookSession. If you are moving the appointments to a different pst or data file, you will need to get the function from this page. It can be pasted at the end of ThisOutlookSession or you can insert a Module and paste it into the module.

To test: Click in the Application_Start then click the Run button. Open the default Inbox and create an appointment. Check the Calendar folders. Is the appointment in the desired folder?

Dim WithEvents newCal As Items
 
Private Sub Application_Startup()
   Dim NS As Outlook.NameSpace
   Set NS = Application.GetNamespace("MAPI")
   Set newCal = NS.GetDefaultFolder(olFolderCalendar).Items
   Set NS = Nothing
End Sub
 
Private Sub newCal_ItemAdd(ByVal Item As Object)

Set CalFolder = GetFolderPath("datafile-display-name\Calendar")
Item.Move CalFolder
End Sub

Move contacts to a different folder

The same method can be used with contacts. Don't forget, if you are moving the appointments to a different pst or data file, you will need to get the function from this page.

Dim WithEvents newContact As Items
 
Private Sub Application_Startup()
   Dim NS As Outlook.NameSpace
   Set NS = Application.GetNamespace("MAPI")
   Set newContact = NS.GetDefaultFolder(olFolderContact).Items
   Set NS = Nothing
End Sub
 
Private Sub newContact_ItemAdd(ByVal Item As Object)

Set ContactFolder = GetFolderPath("datafile-display-name\Contacts")
Item.Move ContactFolder
End Sub

Move Tasks to a different folder

Don't forget, if you are moving the appointments to a different pst or data file, you will need to get the function from this page.

Dim WithEvents newTasks As Items
 
Private Sub Application_Startup()
   Dim NS As Outlook.NameSpace
   Set NS = Application.GetNamespace("MAPI")
   Set newTasks = NS.GetDefaultFolder(olFolderTasks).Items
   Set NS = Nothing
End Sub
 
Private Sub newTasks_ItemAdd(ByVal Item As Object)

Set TaskFolder = GetFolderPath("datafile-display-name\Tasks")
Item.Move TaskFolder
End Sub

Save appointments to a non-default Outlook calendar folder was last modified: October 3rd, 2017 by Diane Poremsky

Related Posts:

  • New Appointments are saved in the wrong calendar
  • Remove reminders from appointments that occur in the past
  • VBA: Copy New Appointments to Another Calendar
  • An administrator recently came to us with a problem: We would like the
    Add to Exchange Server Public Folder Contacts?

About Diane Poremsky

A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

11
Leave a Reply

2500
Photo and Image Files
 
 
 
Audio and Video Files
 
 
 
Other File Types
 
 
 
2500
Photo and Image Files
 
 
 
Audio and Video Files
 
 
 
Other File Types
 
 
 

  Subscribe  
newest oldest most voted
Notify of
paulanthony
paulanthony

Hi Diane. Like a true engineer, you really want this to be right ;-).

I tried the /resetfolders command and it didn't work. Just for fun I tried /resetfoldernames as well which also didn't work.

I am happy to say that blowing away my cached .ost did the trick!

So, that was the good news. Now for the bad. It would seem that the default Contact folder setting didn't work. Changing the code back to: Set newContact = NS.GetDefaultFolder(olFolderContact).Items threw the same error as before.
However, hard coding the path like this: Set newContact = GetFolderPath("[my_default_profile\Contacts (This computer only)").Items does work. It's annoying that the default setting didn't work (I hate hard coding) but at least all of the folders are now in the right place and the code is working as designed.

Vote Up00Vote Down Reply
April 29, 2015 3:08 pm
paulanthony
paulanthony

As soon as I click Start in Application_Startup(), I get:
---------------------------
Microsoft Visual Basic for Applications
---------------------------
Run-time error '-2147024809 (80070057)':

Sorry, something went wrong. You may want to try again.
---------------------------
OK Help
---------------------------

Vote Up00Vote Down Reply
April 24, 2015 8:04 am
Diane Poremsky
Diane Poremsky

That often means the path in the startup macro doesn't exist. What are you using for this line:
Set newCal = NS.GetDefaultFolder(olFolderCalendar).Items

Vote Up00Vote Down Reply
April 24, 2015 12:37 pm
paulanthony
paulanthony

Hi Diane. I am trying to use the Contacts move functions. For that line I have:
Set newContact = NS.GetDefaultFolder(olFolderContact).Items

I think it's a problem with my Outlook though. I was trying all kinds of different things to get Outlook to use my iCloud Contacts as the default and somehow my native Contact folder is now in the Trash and I cannot move it out of the Trash or restore it. The good news is that it won't permanently delete either. I am guess that since it's not in the default location, the macro can't find it.

Vote Up00Vote Down Reply
April 27, 2015 2:20 am
Diane Poremsky
Diane Poremsky

I had a client a few weeks ago that was using iCloud and the contacts folder somehow got moved to the trash. We signed out of iCloud and signed back in.

You can't set the iCloud contacts to be default - outlook needs the default data file to be either a pst or ost - something that has an outbox.

Vote Up00Vote Down Reply
April 28, 2015 9:47 pm
paulanthony
paulanthony

I found the issue and fixed it. The root cause is the fact the my default contacts folder was moved. Here's my working code in case it helps someone else: Dim WithEvents newContact As Items Private Sub Application_Startup() Dim NS As Outlook.NameSpace Set NS = Application.GetNamespace("MAPI") Set contactFolder = GetFolderPath("[my default profile]\Trash\Contacts") Set newContact = contactFolder.Items Set NS = Nothing End Sub Private Sub newContact_ItemAdd(ByVal Item As Object) Set contactFolder = GetFolderPath("iCloud\Contacts") Item.Move contactFolder End Sub Function GetFolderPath(ByVal FolderPath As String) As Outlook.Folder Dim oFolder As Outlook.Folder Dim FoldersArray As Variant Dim i As Integer On Error GoTo GetFolderPath_Error If Left(FolderPath, 2) = "\\" Then FolderPath = Right(FolderPath, Len(FolderPath) - 2) End If 'Convert folderpath to array FoldersArray = Split(FolderPath, "\") Set oFolder = Application.Session.Folders.Item(FoldersArray(0)) If Not oFolder Is Nothing Then For i = 1 To UBound(FoldersArray, 1) Dim SubFolders As Outlook.Folders Set SubFolders = oFolder.Folders Set oFolder = SubFolders.Item(FoldersArray(i)) If oFolder Is Nothing Then Set GetFolderPath = Nothing End If Next End If 'Return the oFolder Set GetFolderPath = oFolder Exit Function GetFolderPath_Error: Set GetFolderPath = Nothing Exit Function End Function

Vote Up00Vote Down Reply
April 29, 2015 2:34 am
Diane Poremsky
Diane Poremsky

While changing the code to look at the trash (Set contactFolder = GetFolderPath("[my default profile]\Trash\Contacts")) works, you really need to get the contacts out of the trash.

Try restarting outlook using the /resetfolders switch. Close Outlook, press Ctrl+R to open Run, type or paste
outlook.exe /resetfolders
and press enter to restart outlook. This *should* put the folder outside of the trash folder, where it belongs.

Or, since you are apparently using imap, delete the ost and let outlook resync it.

Vote Up00Vote Down Reply
April 29, 2015 9:40 am
thomann061
thomann061

I am getting an error: It seems that the function GetFolderPath is not defined...

Vote Up00Vote Down Reply
June 5, 2014 5:33 pm
Diane Poremsky

You need the GetFolderPath function from https://www.slipstick.com/developer/working-vba-nondefault-outlook-folders/

Vote Up00Vote Down Reply
June 5, 2014 6:34 pm
mmiguana
mmiguana

Hi, is there a way to do this if one doesn't know how to program in VBA? THanks.

Vote Up00Vote Down Reply
March 4, 2013 8:36 am
Diane Poremsky

You can use the Move > Move to folder command instead of Save and Close.

Vote Up00Vote Down Reply
March 4, 2013 8:54 am

Visit Slipstick Forums.
What's New at Slipstick.com

Latest EMO: Vol. 24 Issue 3

Support Services

Do you need help setting up Outlook, moving your email to a new computer, migrating or configuring Office 365, or just need some one-on-one assistance?

Subscribe to Exchange Messaging Outlook






Our Sponsors

  • Popular
  • Latest
  • Week Month All
  • Adjusting Outlook's Zoom Setting in Email
  • The Signature or Stationery and Fonts button doesn't work
  • Security Certificate Warning in Microsoft Outlook
  • This operation has been cancelled due to restrictions
  • How to Remove the Primary Account from Outlook
  • Two Copies of Sent Messages in Outlook
  • Outlook's Rules and Alerts: Run a Script
  • iCloud error: Outlook isn't configured to have a default profile
  • Outlook is Not Recognized as the Default Email Client
  • To Cc or Bcc a Meeting Request
  • Outlook.com: Manage Subscriptions
  • Group By Views don’t work in To-Do List
  • Category shortcuts don’t work
  • How to disable the Group By view in Outlook
  • Adjusting Outlook's Zoom Setting in Email
  • Change the Subject of an Incoming Message
  • Creating Signatures in Outlook
  • Scheduling a Recurring Message
  • OneNote is missing from Office 365 / 2019
  • Create Rules using PowerShell
Ajax spinner

Newest VBA Samples

Adjusting Outlook's Zoom Setting in Email

Move email items based on a list of email addresses

Remove prefix from Gmail meeting invitations

How to hide LinkedIn, Facebook, Google and other extra contact folders in Outlook.com

Use VBA to create a Mail Merge from Excel

Open multiple Outlook windows when Outlook starts

Set most frequently used Appointment Time Zones

How to change the From field on incoming messages

VBA: File messages by client code

Update Contact Area Codes

Recent Bugs List

Microsoft keeps a running list of issues affecting recently released updates at Fixes or workarounds for recent issues in Outlook for Windows.

Windows 10 Issues

  • iCloud, Outlook 2016, and Windows 10
  • Better Outlook Reminders?
  • Coming Soon to Windows 10: Office 365 Search
  • Outlook Links Won’t Open In Windows 10
  • BCM Errors after Upgrading to Windows 10
  • Outlook can’t send mail in Windows 10: error Ox800CCC13
  • Missing Outlook data files after upgrading Windows?

Outlook 2016 Top Issues

  • The Windows Store Outlook App
  • Emails are not shown in the People Pane (Fixed)
  • Calendars aren’t printing in color
  • The Signature or Stationery and Fonts button doesn’t work
  • Outlook’s New Account Setup Wizard
  • BCM Errors after October 2017 Outlook Update
  • Excel Files Won’t Display in Reading Pane
  • Outlook 2016: No BCM
  • Exchange Account Set-up Missing in Outlook 2016

VBA Basics

How to use the VBA Editor

Work with open item or selected item

Working with All Items in a Folder or Selected Items

VBA and non-default Outlook Folders

Backup and save your Outlook VBA macros

Get text using Left, Right, Mid, Len, InStr

Using Arrays in Outlook macros

Use RegEx to extract message text

Paste clipboard contents

Windows Folder Picker

Custom Forms

Designing Microsoft Outlook Forms

Set a custom form as default

Developer Resources

Developer Resources

Developer Tools

Outlook-tips.net Samples

VBOffice.net samples

OutlookCode.com

SlovakTech.com

Outlook MVP David Lee

MSDN Outlook Dev Forum

Repair PST

Convert an OST to PST

Repair damaged PST file

Repair large PST File

Remove password from PST

Merge Two Data Files

Sync & Share Outlook Data

  • Share Calendar & Contacts
  • Synchronize two computers
  • Sync Calendar and Contacts Using Outlook.com
  • Sync Outlook & Android Devices
  • Sync Google Calendar with Outlook
  • Access Folders in Other Users Mailboxes
  • “Live” Group Calendar Tools

Convert to / from Outlook

  • Converting Messages and Calendar or
    Address books
  • Moving Outlook to a New Computer
  • Moving Outlook 2010 to a new Windows computer
  • Moving from Outlook Express to Outlook

Recover Deleted Items

  • Recover deleted messages from .pst files
  • Are Deleted Items gone forever in Outlook?

Outlook 2013 Absolute Beginner's Guide

Diane Poremsky [Outlook MVP]

Make a donation

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

Productivity

Productivity Tools

Automatic Message Processing Tools

Special Function Automatic Processing Tools

Housekeeping and Message Management

Task Tools

Project and Business Management Tools

Choosing the Folder to Save a Sent Message In

Run Rules on messages after reading

Help & Suggestions

Outlook Suggestion Box (UserVoice)

Slipstick Support Services

Contact Tools

Data Entry and Updating

Duplicate Checkers

Phone Number Updates

Contact Management Tools

Sync & Share

Share Calendar & Contacts

Synchronize two machines

Sharing Calendar and Contacts over the Internet

More Tools and Utilities for Sharing Outlook Data

Access Folders in Other Users Mailboxes

View Shared Subfolders in an Exchange Mailbox

"Live" Group Calendar Tools

Home | Outlook User | Exchange Administrator | Office 365 | Outlook.com | Outlook Developer
Outlook for Mac | Outlook BCM | Common Problems | Utilities & Addins | Tutorials
Outlook & iCloud Issues | Outlook Apps
EMO Archives | About Slipstick | Advertise | Slipstick Forums
Submit New or Updated Outlook and Exchange Server Utilities

Send comments using our Feedback page
Copyright © 2019 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.

You are going to send email to

Move Comment