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

Move Appointments to an Archive Calendar

Slipstick Systems

› Developer › Move Appointments to an Archive Calendar

Last reviewed on September 19, 2018     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.

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: September 19th, 2018 by Diane Poremsky
Post Views: 32

Related Posts:

  • Working with VBA and non-default Outlook Folders
  • Save appointments to a non-default Outlook calendar folder
  • This macro copies a meeting request to an appointment. Why would you w
    Copy meeting details to an Outlook appointment
  • VBA: Copy New Appointments to Another Calendar

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.

Comments

  1. stephengazard says

    March 25, 2013 at 3:20 am

    perfect thanks

    Reply
  2. stephengazard says

    March 20, 2013 at 5:04 am

    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.

    Reply
    • Diane Poremsky says

      March 20, 2013 at 5:14 am

      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

      Reply
  3. stephengazard says

    March 19, 2013 at 2:01 pm

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

    Reply
    • Diane Poremsky says

      March 19, 2013 at 3:23 pm

      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

      Reply
  4. stephengazard says

    March 18, 2013 at 1:26 am

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

    Reply
    • Diane Poremsky says

      March 18, 2013 at 5:49 am

      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

      Reply
  5. stephengazard says

    March 17, 2013 at 1:52 pm

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

    Reply
    • Diane Poremsky says

      March 17, 2013 at 4:51 pm

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

      Reply
  6. dporemsky says

    March 17, 2013 at 9:05 am

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

    Reply
  7. stephengazard says

    March 14, 2013 at 10:56 am

    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 " & objCalendar.Items.Count & " Meetings Updated"

    End If

    End Sub

    Reply
  8. stephengazard says

    March 12, 2013 at 3:20 am

    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 = Nothing
    Set objFolder = Nothing
    Set objOL = Nothing
    Set objNS = Nothing

    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

    Reply
    • Diane Poremsky says

      March 12, 2013 at 8:52 pm

      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?

      Reply
  9. stephengazard says

    March 8, 2013 at 1:42 pm

    That's fantastic Diane many thanks .... without pushing my luck how would I get this to run on all items in the calendar rather than just current item? Ideally automatically even.

    Really appreciate your help.

    Reply
    • Diane Poremsky says

      March 9, 2013 at 4:09 pm

      You need to tweak it a little to apply to the entire folder- I added a code sample that moves all appointments that ended before 'now'.

      Reply
  10. stephengazard says

    March 7, 2013 at 1:47 pm

    Can someone tell me how I could amend this to move appointments of a particular category?

    Reply
    • Diane Poremsky says

      March 7, 2013 at 2:06 pm

      Something like this should work -

      Public Sub MoveCalendar()

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

      If objAppt.categories = "my category" then
      ' 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 if
      End Sub

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

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

Latest EMO: Vol. 31 Issue 5

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
  • Jetpack plugin with Stats module needs to be enabled.
  • Sync Issues and Errors with Gmail and Yahoo accounts
  • Error Opening iCloud Appointments in Classic Outlook
  • Opt out of Microsoft 365 Companion Apps
  • Mail Templates in Outlook for Windows (and Web)
  • Urban legend: Microsoft Deletes Old Outlook.com Messages
  • Buttons in the New Message Notifications
  • Move Deleted Items to Another Folder Automatically
  • Open Outlook Templates using PowerShell
  • Count and List Folders in Classic Outlook
  • Google Workspace and Outlook with POP Mail
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

Sync Issues and Errors with Gmail and Yahoo accounts

Error Opening iCloud Appointments in Classic Outlook

Opt out of Microsoft 365 Companion Apps

Mail Templates in Outlook for Windows (and Web)

Urban legend: Microsoft Deletes Old Outlook.com Messages

Buttons in the New Message Notifications

Move Deleted Items to Another Folder Automatically

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Google Workspace and Outlook with POP Mail

Newest Code Samples

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

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

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