How to Batch Find and Replace Text in All Tasks in Your Outlook

If you would like to find and replace specific texts in all Outlook tasks, you can make use of the method shared in this article. It can accomplish this task in one go.

To find and replace specific text in one task, you can directly trigger “Find and Replace” feature via “Ctrl + H” key shortcut. However, if you want to process all Outlook tasks in one go, you’d better utilize the following method. It can save you from finding and replacing text one by one manually, which is too troublesome.

Batch Find and Replace Text in All Tasks

  1. At the very outset, start Outlook program.
  2. Then, trigger Outlook VBA editor via “Alt + F11” key buttons.
  3. Next, copy the following code into an unused module.
Dim strFind, strReplace As String

Sub FindReplaceTextsInAllTaskBodies()
    Dim objStore As Outlook.Store
    Dim objFolder As Outlook.Folder
    strFind = InputBox("Type the words to find", , "Test")
    strReplace = InputBox("Type the words to replace", , "Sample")

    If Trim(strFind) <> "" Then
       lTotalCount = 0
       For Each objStore In Application.Session.Stores
           For Each objFolder In objStore.GetRootFolder.Folders
               If objFolder.DefaultItemType = olTaskItem Then
                  Call ProcessTaskFolders(objFolder)
               End If
       MsgBox "Completed!", vbInformation + vbOKOnly
    End If
End Sub

Sub ProcessTaskFolders(ByVal objTaskFolder As Outlook.Folder)
    Dim i As Long
    Dim objTask As Outlook.TaskItem
    Dim objSubTaskFolder As Outlook.Folder
    For i = 1 To objTaskFolder.Items.Count
        Set objTask = objTaskFolder.Items(i)
        If InStr(objTask.Body, strFind) > 0 Then
           'Find and replace text in task body
           objTask.Body = Replace(objTask.Body, strFind, strReplace)
        End If
    'Process all subfolders recursively
    If objTaskFolder.Folders.Count > 0 Then
       For Each objSubTaskFolder In objTaskFolder.Folders
           Call ProcessTaskFolders(objSubTaskFolder)
    End If
End Sub

VBA Code - Batch Find and Replace Text in All Tasks

  1. After that, add this macro to Quick Access Toolbar or ribbon according to “How to Run VBA Code in Your Outlook“.
  2. Finally, you can try it by the following steps.
  • First off, click the macro button in Quick Access Toolbar or ribbon.
  • Then, enter the specific texts for find and replace.Enter Specific Text for Find and Replace
  • Ultimately, click “OK”. At once, the specific text in all tasks will be altered to the target text.Batch Replaced Text in Tasks

Restore Damaged Outlook Data

As we all know, Outlook data is vulnerable. For instance, frequent exiting Outlook improperly can result in Outlook corruption readily. Therefore, it is highly wise to keep a powerful and credible Outlook repair tool, like DataNumen Outlook Repair, in vicinity. It can help you a lot in the event of Scanpst failure.

Author Introduction:

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

Comments are closed.