• Outlook User
  • New Outlook app
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
  • Developer
  • Microsoft 365 Admin
    • Common Problems
    • Microsoft 365
    • Outlook BCM
    • Utilities & Addins

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     13 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:

  • Move Appointments to an Archive Calendar
  • VBA: Copy New Appointments to Another Calendar
  • New Appointments are saved in the wrong calendar
  • Use a VBA macro to monitor a folder in a secondary mailbox for new mes
    Monitor secondary mailbox folder for new messages

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.

Subscribe
Notify of
13 Comments
newest
oldest most voted
Inline Feedbacks
View all comments

Kevin Brisebois (@guest_218844)
October 30, 2021 3:41 pm
#218844

Hi Diane,
i'm working on a small macro to create new appointments in Outlook Calendar based on Microsoft projects Tasks list.
Here is my working code so far:

Sub ExportToOutlook()
Dim ol As Outlook.Application
Dim olAp As Outlook.AppointmentItem
Dim proj As Project
Dim t As Task
Dim pj As Project
Set pj = ActiveProject
For Each t In pj.Tasks
Set ol = New Outlook.Application
Set olAp = ol.CreateItem(olAppointmentItem)
With olAp
    .Subject = t.Name
    .Start = t.Start
    .End = t.Finish
    .Save
    End With
Next t
End Sub
How can i use this code to insert in another calendar based on a combobox filled with calendar names

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Kevin Brisebois
October 30, 2021 8:45 pm
#218845

This uses the default calendar
Set olAp = ol.CreateItem(olAppointmentItem)

to save to a new calendar, you need to use items.add - if you are selecting a name from a list, use the variable in the path (this uses a subfolder of the calendar)
Set calFolder = Ns.GetDefaultFolder(olFolderCalendar).Folders(calName)
Set olAp = calFolder.Items.Add(olAppointmentItem)

0
0
Reply
paulanthony (@guest_190676)
April 29, 2015 3:08 pm
#190676

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.

0
0
Reply
paulanthony (@guest_190534)
April 24, 2015 8:04 am
#190534

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
---------------------------

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  paulanthony
April 24, 2015 12:37 pm
#190538

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

0
0
Reply
paulanthony (@guest_190576)
Reply to  paulanthony
April 27, 2015 2:20 am
#190576

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.

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  paulanthony
April 28, 2015 9:47 pm
#190625

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.

0
0
Reply
paulanthony (@guest_190645)
Reply to  paulanthony
April 29, 2015 2:34 am
#190645

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

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  paulanthony
April 29, 2015 9:40 am
#190657

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.

0
0
Reply
thomann061 (@guest_183803)
June 5, 2014 5:33 pm
#183803

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

0
0
Reply
Diane Poremsky (@guest_183804)
Reply to  thomann061
June 5, 2014 6:34 pm
#183804

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

0
0
Reply
mmiguana (@guest_174426)
March 4, 2013 8:36 am
#174426

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

0
0
Reply
Diane Poremsky (@guest_174428)
Reply to  mmiguana
March 4, 2013 8:54 am
#174428

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

0
0
Reply

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

Latest EMO: Vol. 30 Issue 15

Subscribe to Exchange Messaging Outlook






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?

Our Sponsors

CompanionLink
ReliefJet
  • Popular
  • Latest
  • Week Month All
  • Use Classic Outlook, not New Outlook
  • How to Remove the Primary Account from Outlook
  • Disable "Always ask before opening" Dialog
  • Adjusting Outlook's Zoom Setting in Email
  • This operation has been cancelled due to restrictions
  • Remove a password from an Outlook *.pst File
  • Reset the New Outlook Profile
  • Maximum number of Exchange accounts in an Outlook profile
  • Save Attachments to the Hard Drive
  • How to Hide or Delete Outlook's Default Folders
  • Google Workspace and Outlook with POP Mail
  • Import EML Files into New Outlook
  • Opening PST files in New Outlook
  • New Outlook: Show To, CC, BCC in Replies
  • Insert Word Document into Email using VBA
  • Delete Empty Folders using PowerShell
  • Warn Before Deleting a Contact
  • Classic Outlook is NOT Going Away in 2026
  • Use PowerShell to Delete Attachments
  • Remove RE:, FWD:, and Other Prefixes from Subject Line
Ajax spinner

Recent Bugs List

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

For new Outlook for Windows: Fixes or workarounds for recent issues in new Outlook for Windows .

Outlook for Mac Recent issues: Fixes or workarounds for recent issues in Outlook for Mac

Outlook.com Recent issues: Fixes or workarounds for recent issues on Outlook.com

Office Update History

Update history for supported Office versions is at Update history for Office

Outlook Suggestions and Feedback

Outlook Feedback covers Outlook as an email client, including Outlook Android, iOS, Mac, and Windows clients, as well as the browser extension (PWA) and Outlook on the web.

Outlook (new) Feedback. Use this for feedback and suggestions for Outlook (new).

Use Outlook.com Feedback for suggestions or feedback about Outlook.com accounts.

Other Microsoft 365 applications and services




New Outlook Articles

Google Workspace and Outlook with POP Mail

Import EML Files into New Outlook

Opening PST files in New Outlook

New Outlook: Show To, CC, BCC in Replies

Insert Word Document into Email using VBA

Delete Empty Folders using PowerShell

Warn Before Deleting a Contact

Classic Outlook is NOT Going Away in 2026

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Newest Code Samples

Insert Word Document into Email using VBA

Warn Before Deleting a Contact

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Change the Mailing Address Using PowerShell

Categorize @Mentioned Messages

Send an Email When You Open Outlook

Delete Old Calendar Events using VBA

Use PowerShell or VBA to get Outlook folder creation date

Rename Outlook Attachments

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

VBOffice.net samples

SlovakTech.com

Outlook MVP David Lee

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

Diane Poremsky [Outlook MVP]

Make a donation

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

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

Submit Outlook Feature Requests

Slipstick Support Services

Buy Microsoft 365 Office Software and Services

Visit Slipstick Forums.

What's New at Slipstick.com

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

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

wpDiscuz

Sign up for Exchange Messaging Outlook

Our weekly Outlook & Exchange newsletter (bi-weekly during the summer)






Please note: If you subscribed to Exchange Messaging Outlook before August 2019, please re-subscribe.

Never see this message again.

You are going to send email to

Move Comment