Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to search and replace appointment subject in Outlook calendar?

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

Office Tab - Enable Tabbed Editing and Browsing in Office, and Make Work Much Easier...
Kutools for Outlook - Brings 100 Powerful Advanced Features to Microsoft Outlook
  • Auto CC/BCC by rules when sending email; Auto Forward Multiple Emails by rules; Auto Reply without exchange server, and more automatic features...
  • BCC Warning - show message when you try to reply all if your mail address is in the BCC list; Remind When Missing Attachments, and more remind features...
  • Reply (All) With All Attachments in the mail conversation; Reply Many Emails at once; Auto Add Greeting when reply; Auto Add Date&Time into subject...
  • Attachment Tools: Auto Detach, Compress All, Rename All, Auto Save All... Quick Report, Count Selected Mails, Remove Duplicate Mails and Contacts...
  • More than 100 advanced features will solve most of your problems in Outlook 2010-2019 and 365. Full features 60-day free trial.

arrow blue right bubbleSearch 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.

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:

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.

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:

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.

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

7. In the third Microsoft Outlook dialog box, enter the text that you like to replace, and click OK.

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.

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

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

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


Kutools for Outlook - Brings 100 Advanced Features to Outlook, and Make Work Much Easier!

  • Auto CC/BCC by rules when sending email; Auto Forward Multiple Emails by custom; Auto Reply without exchange server, and more automatic features...
  • BCC Warning - show message when you try to reply all if your mail address is in the BCC list; Remind When Missing Attachments, and more remind features...
  • Reply (All) With All Attachments in the mail conversation; Reply Many Emails in seconds; Auto Add Greeting when reply; Add Date into subject...
  • Attachment Tools: Manage All Attachments in All Mails, Auto Detach, Compress All, Rename All, Save All... Quick Report, Count Selected Mails...
  • Powerful Junk Emails by custom; Remove Duplicate Mails and Contacts... Enable you to do smarter, faster and better in Outlook.
shot kutools outlook kutools tab 1180x121
shot kutools outlook kutools plus tab 1180x121
 
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Dominic · 2 years ago
    I always get a Syntax Error right at the start on the 2nd line at Dim oApp As Outlook.Application. No idea what's wrong :-(

    I try to run the VB Script in Outlook 2016 (O365 Version) on Windows 10.
  • To post as a guest, your comment is unpublished.
    Aaron · 2 years ago
    It seems I'm unable to do this for non-local, or shared calendars. Does anyone know how to do it for shared calendars? I'm set as "owner" for permission level of the shared calendar, but it won't show up in my list of folders when I run the script, only my locally created calendars show up.
  • To post as a guest, your comment is unpublished.
    LordJair · 3 years ago
    Worked fantastically! Thank you so much!!!
    • To post as a guest, your comment is unpublished.
      Dale R · 2 years ago
      This should do it for you. Add these 3 lines immediately after line 8 (Set oApp = Outlook.Application).

      Dim nmSpace As Outlook.NameSpace
      Set nmSpace = oApp.GetNamespace("MAPI")
      Set oCalFolder = nmSpace.GetDefaultFolder(olFolderCalendar)
  • To post as a guest, your comment is unpublished.
    Armin · 3 years ago
    Thank you!
    How can we modify it to always use the same calendar, and not show the first pop-up?

    thank you
  • To post as a guest, your comment is unpublished.
    Amos · 3 years ago
    Worked just fine
    really good
    It took me some time to understand that this is case sensitive, but that is very good.

    Thank you