How to Quickly Archive All Overdue Appointments and Tasks in Your Outlook

Outlook doesn’t provide a direct feature for archiving all overdue appointments and tasks rapidly. Thus, in this article, we will tell you how to programmatically achieve it.

By default, to archive items, you can use the two functions in Outlook – “Archive” and “Auto Archive”. However, by either means, if you would like to archive all the overdue appointments and tasks, you have to first find out such items and move them to a specific folder, and lastly archive the whole folder. Without any doubts, it is troublesome. Thus, thereinafter, we’ll share you a much faster way.

Quickly Archive All Overdue Appointments and Tasks in Your Outlook

Archive All Overdue Appointments and Tasks

  1. At the very outset, launch your Outlook program.
  2. Then, in the subsequent Outlook main screen, you need to press “Alt + F11” keys to access VBA editor.
  3. Next, in the “Microsoft Visual Basic for Applications” window, you ought to open an unused module or simply insert a new one.
  4. Later, you need to copy the following VBA code into this module.
Dim objArchivePSTFile As Folder
Dim objArchiveFolder As Folder

Sub Archive_AllOverdueAppointmentsTasks()
    Dim objSourcePSTFile As Folder
    Dim objFolder As Folder
 
    'Open the specific Archive Outlook PST file in your Outlook
    Application.Session.AddStore "C:\Users\Test\Documents\Outlook Files\Archive.pst"
    Set objArchivePSTFile = Application.Session.folders("Archives")
 
    Set objSourcePSTFile = Application.Session.folders("John Smith")
 
    For Each objFolder In objSourcePSTFile.folders
        Call ProcessFolders(objFolder)
    Next
 
    'Remove the Archive PST file from your Outlook
    Application.Session.RemoveStore objArchivePSTFile
 
    MsgBox "All Overdue Appointments & Tasks Archived!", vbInformation
End Sub

Sub ProcessFolders(ByVal objCurrentFolder As Folder)
    Dim obTasks As Items
    Dim objTask As TaskItem
    Dim objAppointments As Items
    Dim objAppointment As AppointmentItem
    Dim objSubfolder As Folder
 
    If objCurrentFolder.DefaultItemType = olTaskItem Then
 
       On Error Resume Next
       Set objArchiveFolder = objArchivePSTFile.folders(objCurrentFolder.Name)
       If objArchiveFolder Is Nothing Then
          Set objArchiveFolder = objArchivePSTFile.folders.Add(objCurrentFolder.Name)
       End If
   
       Set objTasks = objCurrentFolder.Items
 
       'Archive overdue tasks
       For Each objTask In objTasks
           If objTask.DueDate < Date Then
              objTask.Move objArchivePSTFile
           End If
       Next
    ElseIf objCurrentFolder.DefaultItemType = olAppoinmentItem Then
 
       On Error Resume Next
       Set objArchiveFolder = objArchivePSTFile.folders(objCurrentFolder.Name)
       If objArchiveFolder Is Nothing Then
          Set objArchiveFolder = objArchivePSTFile.folders.Add(objCurrentFolder.Name)
       End If
 
       Set objAppointments = objCurrentFolder.Items
 
       'Archive overdue appointments
       For Each objAppointment In objAppointments
           If (objAppointment.Start < Date) And (objAppointment.End < Date) Then
              objAppointment.Move objArchivePSTFile
           End If
       Next
    End If
 
    'Process all subfolders recursively
    If objCurrentFolder.folders.count > 0 Then
       For Each objSubfolder In objCurrentFolder.folders
           Call ProcessFolders(objSubfolder)
       Next
    End If
End Sub

VBA Code - Archive All Overdue Appointments and Tasks

  1. After that, you need to insure whether macros are enabled in your Outlook.
  • Exit the current window.
  • Then go to “File” > “Options” > “Trust Center” > “Trust Center Settings” > “Macro Settings”.
  • Next select “Enable all macros” option and press “OK”.
  1. Finally you can try this new macro.
  • First, go back to the macro window.
  • Then click the “Run” icon in toolbar or simply press F5 key button.
  • After the macro finishes, you will see that all the overdue appointments and tasks have been archived.

Outlook Is Prone to Error & Corruption

Although Outlook comes loaded with numerous proficient capabilities, it cannot keep far away from errors and corruption. Thus, as an Outlook regular user, you’d better make some precautions, like creating consistent PST backups to safeguard your Outlook data. Moreover, you have to prepare an experienced repair tool, say DataNumen Outlook Repair. It can come in handy in the case where the backups cannot be recovered and inbox repair tool fails.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including recover Sql Server and outlook repair software products. For more information visit www.datanumen.com

Leave a Reply

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