Skip to main content

Kutools for Office — One Suite. Five Tools. Get More Done.

How to search and replace appointment subject in Outlook calendar?

Author Siluvia Last modified

Find and replace appointment subject in Outlook calendar is helpful when you find some subjects need to be replaced with same texts in mass. Or replace the word Copy in the subject field after data importing in Outlook. This article provides you with VBA code to search and replace multiple appointment subjects. Please browse for more details.

Search and replace appointment subject with VBA code


Search and replace appointment subject with VBA code

In this section, you can search and replace appointment subject with VBA code as follows.

1. Firstly you need to set macro settings to low in your Outlook.

1) In Outlook 2010 and 2013, click "File" > "Options". And in the "Outlook Options" dialog box, click "Trust Center" in the left bar, then click the "Trust Center Settings" button.

doc-find-and-replace-subject-1

In the "Trust Center" dialog box, click "Macro Settings" in the left bar, then select "Enable all macros" option in the "Macro Settings" section. And click the "OK" button. See screenshot:

doc-find-and-replace-subject-2

2) In Outlook 2007, please click "Tools" > "Trust Center". In the "Trust Center" dialog box, click "Macro Settings" in the left bar, then select "No security check for macros" option and click the "OK" button.

doc-find-and-replace-subject-3

2. Press the "Alt" + "F11" keys to open the "Microsoft Visual Basic for Applications" window.

3. In the "Microsoft Visual Basic for Applications" window, double-click to expand the "project1" > "Microsoft Outlook Objects" > "ThisOutlookSession" to open the VBA editor. See screenshot:

doc-find-and-replace-subject-4

4. Copy and paste the following VBA code into the VBA editor. And then press the "F5" key to run the code.

VBA: find and replace appointment subject

Sub FindReplaceAppointment()
    Dim oApp As Outlook.Application
    Dim oCalFolder As Outlook.MAPIFolder
    Dim oAppt As Outlook.AppointmentItem
    Dim sOldText As String
    Dim sNewText As String
    Dim iCalChangedCount As Integer
    Set oApp = Outlook.Application
    MsgBox ("This script will perform a find/replace in the subject line of all appointments in a specified calendar.")
    sOldText = InputBox("What is the text string that you would like to replace?")
    sNewText = InputBox("With what would you like to replace it?")
    ' Check to be sure a Calendar folder was selected
    Do
    If Not (oCalFolder Is Nothing) Then
        If (oCalFolder.DefaultItemType = olAppointmentItem) Then Exit Do
    End If
    MsgBox ("Please select a calendar folder from the following list.")
    Set oCalFolder = Application.Session.PickFolder
    On Error GoTo ErrHandler:
    Loop Until oCalFolder.DefaultItemType = olAppointmentItem
    ' Loop through appointments in calendar, change text where necessary, keep count
    iCalChangedCount = 0
    For Each oAppt In oCalFolder.Items
        If InStr(oAppt.Subject, sOldText) <> 0 Then
            Debug.Print "Changed: " & oAppt.Subject & " - " & oAppt.Start
            oAppt.Subject = Replace(oAppt.Subject, sOldText, sNewText)
            oAppt.Save
            iCalChangedCount = iCalChangedCount + 1
        End If
    Next
    ' Display results and clear table
    MsgBox (iCalChangedCount & " appointments had text in their subjects changed from '" & sOldText & "' to '" & sNewText & "'.")
    Set oAppt = Nothing
    Set oCalFolder = Nothing
Exit Sub
ErrHandler:
    MsgBox ("Macro terminated.")
End Sub

5. After running the code, a "Microsoft Outlook" dialog box pops up. Click the "OK" button.

doc-find-and-replace-subject-5

6. In the second "Microsoft Outlook" dialog box, enter the text that you would like to replace, and then click the "OK" button.

doc-find-and-replace-subject-6

7. In the third "Microsoft Outlook" dialog box, enter the text that you would like to use as replacement, and click "OK".

doc-find-and-replace-subject-7

Note: If you just want to remove all “Copy” words from the subject in the specified calendar, please leave this box blank.

8. Click the "OK" button in the below dialog box.

doc-find-and-replace-subject-8

9. In the "Select Folder" dialog box, select your calendar under the specified email account, and then click the "OK" button. See screenshot:

doc-find-and-replace-subject-9

10. Then a dialog box will pop up to inform you that the replacement is successful. Please click the "OK" button.

doc-find-and-replace-subject-10

11. And then all the texts in your subjects of selected calendar have been replaced with the new content.


Best Office Productivity Tools

Breaking News: Kutools for Outlook Launches Free Version!

Experience the all-new Kutools for Outlook with 100+ incredible features! Click to download now!

🤖 Kutools AI : Uses advanced AI technology to handle emails effortlessly, including replying, summarizing, optimizing, extending, translating, and composing emails.

📧 Email Automation: Auto Reply (Available for POP and IMAP)  /  Schedule Send Emails  /  Auto CC/BCC by Rules When Sending Email  /  Auto Forward (Advanced Rules)   /  Auto Add Greeting   /  Automatically Split Multi-Recipient Emails into Individual Messages ...

📨 Email Management: Recall Emails  /  Block Scam Emails by Subjects and Others  /  Delete Duplicate Emails  /  Advanced Search  /  Consolidate Folders ...

📁 Attachments ProBatch Save  /  Batch Detach  /  Batch Compress  /  Auto Save   /  Auto Detach  /  Auto Compress ...

🌟 Interface Magic: 😊More Pretty and Cool Emojis   /  Remind you when important emails come  /  Minimize Outlook Instead of Closing ...

👍 One-click Wonders: Reply All with Attachments  /   Anti-Phishing Emails  /  🕘Show Sender's Time Zone ...

👩🏼‍🤝‍👩🏻 Contacts & Calendar: Batch Add Contacts From Selected Emails  /  Split a Contact Group to Individual Groups  /  Remove Birthday Reminders ...

Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Instantly unlock Kutools for Outlook with a single click. Don't wait, download now and boost your efficiency!

kutools for outlook features1 kutools for outlook features2

🚀 One-Click Download — Get All Office Add-ins

Strongly Recommended: Kutools for Office (5-in-1)

One click to download five installers at once — Kutools for Excel, Outlook, Word, PowerPoint and Office Tab Pro. Click to download now!

  • One-click convenience: Download all five setup packages in a single action.
  • 🚀 Ready for any Office task: Install the add-ins you need, when you need them.
  • 🧰 Included: Kutools for Excel / Kutools for Outlook / Kutools for Word / Office Tab Pro / Kutools for PowerPoint