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

Move Appointments to an Archive Calendar

Slipstick Systems

› Developer › Move Appointments to an Archive Calendar

Last reviewed on February 13, 2018   —  17 Comments

September 23, 2012 by Diane Poremsky 17 Comments

This code removes the reminder and categories and moves the appointment to a calendar in an archive folder or a subfolder under the calendar.

Petros asked
I want to be able to do 3 things with just one click of a button:

With a Calendar event selected, I want to:
1) Erase any Reminder (set Reminder to: 'None'),
2) Clear All Categories,
3) Move the event to another calendar (in My Calendars) named "DONE" (where I keep finished-completed things).

Since this is something I do everyday, multiple times a day, I want to save time by having a macro do all those things with one click.

Removing the reminder and clearing categories is as simple as changing the field values. Moving the event is also a simple process , although it requires a function that gets the filepath if the calendar you are moving the event to is not in the default data file.

The code Set CalFolder = GetFolderPath("Archive\Done") moves the appointment to a calendar folder called "Done" in the Archive pst.

Use Set CalFolder = Session.GetDefaultFolder(olFolderCalendar).Folders("Done") to move the appointments to a subfolder of the calendar. Note: if you are moving the item to a subfolder of the data file, you don't need to use the GetFolderPath function.

For more information on folders and data files, see Working with VBA and non-default Outlook Folders.

The GetCurrentItem function detects whether the appointment is selected or opened. For more information, see Outlook VBA: work with open item or selected item.

Public Sub MoveCalendar()

Dim objAppt As Outlook.AppointmentItem
Set objAppt = GetCurrentItem()

' move to a calendar in an archive data file
Set CalFolder = GetFolderPath("Archive\Done")

' change field values here
With objAppt
    .ReminderSet = False
    .Categories = ""
End With

    objAppt.Move CalFolder
 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

Function GetCurrentItem() As Object
    Dim objApp As Outlook.Application
             
    Set objApp = Application
    On Error Resume Next
    Select Case TypeName(objApp.ActiveWindow)
        Case "Explorer"
            Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
        Case "Inspector"
            Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
    End Select
         
    Set objApp = Nothing
End Function

Move all appointments

This code sample moves all appointments with an End time before "Now", to the archive folder.

Public Sub MoveAllAppointments()
    Dim objOL As Outlook.Application
    Dim objNS As Outlook.NameSpace
    Dim objAppt As Outlook.Items
    Dim objFolder As Outlook.MAPIFolder
 
    On Error Resume Next
 
    Set objOL = CreateObject("Outlook.Application")
    Set objNS = objOL.GetNamespace("MAPI")
    Set objFolder = objNS.GetDefaultFolder(olFolderCalendar)
    Set objAppt = objFolder.Items
 
' move to a calendar in an archive data file
Set CalFolder = GetFolderPath("Archive\Done")

For i = objAppt.Count To 1 Step -1
  
If objAppt(i).End < Now Then
         
' change field values here
With objAppt(i)
    .ReminderSet = False
    .Categories = ""
End With

objAppt(i).Move CalFolder
    End If

Next i

    Set objAppt = Nothing
    Set objFolder = Nothing
    Set objOL = Nothing
    Set objNS = Nothing

    
 End Sub

Move Appointments to an Archive Calendar was last modified: February 13th, 2018 by Diane Poremsky
  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on Google+ (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Reddit (Opens in new window)
  • Share on Skype (Opens in new window)
  • Click to share on Pocket (Opens in new window)
  • Click to share on Tumblr (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
  • Click to print (Opens in new window)

Related Posts:

  • Working with VBA and non-default Outlook Folders
  • Save appointments to a non-default Outlook calendar folder
  • Save New Contacts to iCloud Contacts
  • Create an Outlook Appointment from a Message

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.

Leave a Reply

17 Comments on "Move Appointments to an Archive Calendar"

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
stephengazard
stephengazard
Share On TwitterShare On Google

perfect thanks

Vote Up00Vote Down Reply
March 25, 2013 3:20 am
stephengazard
stephengazard
Share On TwitterShare On Google

Sorry Diane I am sure I am being dum ... but I've done that but it appears to now run the process on the sub calendar "Call Log" rather than run the process on the default calendar and then move the appointment to the sub calendar on completion.

Vote Up00Vote Down Reply
March 20, 2013 5:04 am
Diane Poremsky
Share On TwitterShare On Google

Oh, sorry about that. I misunderstood. You want to mark and move the appointments? You need to add this and the getfolderpath function. (It's in the first sample on this page too.)

This can go before the For each..
Set CalFolder = GetFolderPath("ArchiveDone")

And this after the .save but before the End if and Next lines.
objAppt.Move CalFolder

Vote Up00Vote Down Reply
March 20, 2013 5:14 am
stephengazard
stephengazard
Share On TwitterShare On Google

Thanks Diane, .... how do I get the move to work to the sub calendar though? I can't get that to work.

Vote Up00Vote Down Reply
March 19, 2013 2:01 pm
Diane Poremsky
Share On TwitterShare On Google

If the subcalendar is in the same data file as the calendar, you'd use

Set objCalendar = Session.GetDefaultFolder(olFolderCalendar).Folders("SharedCal")

instead of
Set objCalendar = Application.Session.GetDefaultFolder(olFolderCalendar)

Working with other folders

Vote Up00Vote Down Reply
March 19, 2013 3:23 pm
stephengazard
stephengazard
Share On TwitterShare On Google

Really? That part seems to work for me it is the move that doesn't.

If I wanted to replace the SQL then with an if stmt will tag help?

All the relevant appointments start with "C."

Vote Up00Vote Down Reply
March 18, 2013 1:26 am
Diane Poremsky
Share On TwitterShare On Google

The Keyword was the problem - with that gone the filter works and the macro completes.

I ended up using this filter to speed things up as I have like 1500 appointments and it ran through each - I had added a msgbox location to see what the restriction was returning. :)
strRestriction = "@SQL= (""urn:schemas:httpmail:subject"" LIKE '@Call%' OR ""urn:schemas:httpmail:subject"" LIKE 'C%' AND %last7days(""urn:schemas:calendar:dtstart"")%)"

In this block:
For Each aItem In objCalendar.Items
If Mid(aItem.subject, 1, 2) = "C." Then

you don't identify what an aItem is.

I moved the subject editing code up into the If loop:

objAppt.Categories = "S. CALL MADE."
End If

' my tests had call as the first word
strTemp = Right(objAppt.Subject, (Len(objAppt.Subject) - 5))
objAppt.Subject = strTemp
MsgBox strTemp
iItemsUpdated = iItemsUpdated + 1

objAppt.Save

If the goal of this is to not process previously processed items, you could look for categories. (the location code allows for case variations on the case and spaces at the end.)
If InStr(1, Item.Categories) "Call" Then
If Left(LCase(objAppt.Location), 11) = "missed call" Then

You could check categories in the sql filter code instead of in the loop.

my version is at steve-macro.txt

Vote Up00Vote Down Reply
March 18, 2013 5:49 am
stephengazard
stephengazard
Share On TwitterShare On Google

Yes works fine using SQL simply as I adapted from someone else code.

Vote Up00Vote Down Reply
March 17, 2013 1:52 pm
Diane Poremsky
Share On TwitterShare On Google

It's failing here on the SQL (in the macro at least).

Vote Up00Vote Down Reply
March 17, 2013 4:51 pm
dporemsky
Share On TwitterShare On Google

Does the SQL filter work as expected in custom views? Is there a reason you are using that filter instead of an If statement? If instr( item.subject, "call") then...

Vote Up00Vote Down Reply
March 17, 2013 9:05 am
stephengazard
stephengazard
Share On TwitterShare On Google
other code: Private Sub Application_Reminder(ByVal Item As Object) If Item.subject = "Process Calls" Then ' Define variables Dim objCalendar As Outlook.folder Dim objItems As Outlook.Items Dim objAppt As Outlook.AppointmentItem Dim strRestriction As String Dim objFinalItems As Outlook.Items Dim myolApp As Outlook.Application ' Set strRestriction to be only calls strRestriction = "@SQL= (""urn:schemas:httpmail:subject"" LIKE '@Call.%' OR ""urn:schemas:httpmail:subject"" LIKE 'C.%' OR ""urn:schemas:httpmail:subject"" LIKE '@Call in%' OR ""urn:schemas:httpmail:subject"" LIKE '@Call%') AND ""urn:schemas-microsoft-com:office:office#Keywords"" 'Phone call'" ' Set the objCalendar and objItems items Set objCalendar = Application.Session.GetDefaultFolder(olFolderCalendar) Set objItems = objCalendar.Items Set objFinalItems = objItems.Restrict(strRestriction) Set myolApp = CreateObject("Outlook.Application") For Each objAppt In objFinalItems ' Debugging ' Debug.Print objAppt.Start, objAppt.Subject, objAppt.Categories ' Assign the category to the appointments If objAppt.Location = "Missed Call " Then objAppt.Categories = "S. CALL MISSED." ElseIf objAppt.Location = "Incoming Call " Then objAppt.Categories = "S. CALL RECEIVED." Else objAppt.Categories = "S. CALL MADE." End If objAppt.Save Next ' Rename Entry Dim iItemsUpdated As Integer Dim strTemp As String iItemsUpdated = 0 For Each aItem In objCalendar.Items If Mid(aItem.subject, 1, 2) = "C." Then strTemp = Mid(aItem.subject, 4, Len(aItem.subject) - 4) aItem.subject = strTemp iItemsUpdated = iItemsUpdated + 1 End If aItem.Save Next aItem MsgBox iItemsUpdated & " of " &… Read more »
Vote Up00Vote Down Reply
March 14, 2013 10:56 am
stephengazard
stephengazard
Share On TwitterShare On Google
Thanks Diane, I think I am getting there but struggling a bit .... I have two processes (I am sure the could be shortened to one mind you but everytime I try I break it !) ... First process sets category of appointment based on Subject and location (all works ok). The second process "MoveCallLog" should (but doesn't) ... move only those appointments that carry the category of "Calls" to a sub calendar called "Call Log" I can't get it to work - it either doesn't fire or moves everything! Also is there a way to automate more regularly than daily via the task reminder? Your help would be MUCH appreciated. Code below: Private Sub Application_Reminder(ByVal Item As Object) If Item.subject = "Move Calls" Then Public Sub MoveACallLog() Dim objOL As Outlook.Application Dim objNS As Outlook.NameSpace Dim objAppt As Outlook.Items Dim objFolder As Outlook.MAPIFolder On Error Resume Next Set objOL = CreateObject("Outlook.Application") Set objNS = objOL.GetNamespace("MAPI") Set objFolder = objNS.GetDefaultFolder(olFolderCalendar) Set objAppt = objFolder.Items ' move to a calendar in an archive data file Set CalFolder = GetFolderPath("\stephen@gazard.netCalendarCall Log") For i = objAppt.Count To 1 Step -1 If objAppt(i).Categories = "Calls" Then objAppt(i).Move CalFolder End If Next i Set objAppt… Read more »
Vote Up1-1Vote Down Reply
March 12, 2013 3:20 am
Diane Poremsky
Share On TwitterShare On Google

On the more regular part - you can set up more tasks with different reminder times. Add code to mark the task complete and save it, and recurring tasks will keep running. Otherwise, you need some way to trigger it since Outlook doesn't have a timer.

I think the code is probably not running, if its waiting for the first code to set the category. What is the full code for the other macro?

Vote Up1-1Vote Down Reply
March 12, 2013 8:52 pm

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

Latest EMO: Vol. 23 Issue 10

Subscribe to Exchange Messaging Outlook






Our Sponsors

  • Popular
  • Latest
  • Week Month All
  • This operation has been cancelled due to restrictions This operation has been cancelled due to restrictions
  • Adjusting Outlook's Zoom Setting in Email Adjusting Outlook's Zoom Setting in Email
  • How to Remove the Primary Account from Outlook How to Remove the Primary Account from Outlook
  • Pictures Don't Display in Outlook Messages Pictures Don't Display in Outlook Messages
  • Outlook is Not Recognized as the Default Email Client Outlook is Not Recognized as the Default Email Client
  • To Cc or Bcc a Meeting Request To Cc or Bcc a Meeting Request
  • Remove a password from an Outlook *.pst File Remove a password from an Outlook *.pst File
  • The Signature or Stationery and Fonts button doesn't work The Signature or Stationery and Fonts button doesn't work
  • Understanding Outlook's Auto-Complete Cache (*.NK2) Understanding Outlook's Auto-Complete Cache (*.NK2)
  • Exchange Account Set-up Missing in Outlook 2016 Exchange Account Set-up Missing in Outlook 2016
  • iCloud error: Outlook isn't configured to have a default profile iCloud error: Outlook isn't configured to have a default profile
  • Setting Custom Reminder Times Setting Custom Reminder Times
  • Add Additional Addresses to Room Mailboxes Add Additional Addresses to Room Mailboxes
  • Create a Task from a Message and include the Attachment Create a Task from a Message and include the Attachment
  • Forward email messages by date Forward email messages by date
  • Open multiple Outlook windows when Outlook starts Open multiple Outlook windows when Outlook starts
  • Office 365 Fraud Detection Checks Office 365 Fraud Detection Checks
  • Outlook Request: Calendar Details View Outlook Request: Calendar Details View
  • Outlook's "Not Junk" option isn't available Outlook's "Not Junk" option isn't available
  • Outlook Tip: Show all Mondays in the Calendar Outlook Tip: Show all Mondays in the Calendar
Ajax spinner

Newest VBA Samples

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

Set a reminder on selected items in the To-Do List

Replicate GTD: Create a task after sending a message

Use VBA to read fields in attached messages

Move Outlook Folders using VBA

Replicate Smart Lookup using a macro

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 © 2018 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.

You are going to send email to

Move Comment