跳到主要内容

如何在Outlook日历中搜索和替换约会主题?

当您发现某些主题需要大量替换为相同的文本时,在Outlook日历中查找和替换约会主题会很有用。 或在Outlook中导入数据后,在主题字段中替换“复制”一词。 本文为您提供了VBA代码,以搜索和替换多个约会主题。 请浏览以获取更多详细信息。

搜索并将约会主题替换为VBA代码

Office 选项卡 - 在 Microsoft Office 中启用选项卡式编辑和浏览,让工作变得轻而易举
Kutools for Outlook - 通过 100 多个高级功能增强 Outlook,实现卓越效率
使用这些高级功能增强您的 Outlook 2021 - 2010 或 Outlook 365。 享受全面的 60 天免费试用并提升您的电子邮件体验!

箭头蓝色右气泡搜索并将约会主题替换为VBA代码

在此部分中,您可以按以下方式搜索并用VBA代码替换约会主题。

1.首先,您需要在Outlook中将宏设置设置为低。

1)在Outlook 2010和2013中,单击 文件 > 附加选项. 而在 Outlook选项 对话框,单击 信任中心 在左侧栏中,然后点击 信任中心设置 按钮。

信任中心 对话框,单击 宏设置 在左侧栏中,然后选择 启用所有宏 在选项 宏设置 部分。 然后点击 OK 按钮。 看截图:

2)。 在Outlook 2007中,请单击 工具 > 信任中心。 在 信任中心 对话框,单击 宏设置 在左侧栏中,然后选择 没有对宏的安全检查 选项,然后单击 OK 按钮。

2。 按 其他 + F11 键打开 Microsoft Visual Basic应用程序 窗口。

3.在 Microsoft Visual Basic应用程序 窗口,双击以展开 project1 > Microsoft Outlook对象 > 本次展望会议 打开VBA编辑器。 看截图:

4.将以下VBA代码复制并粘贴到VBA编辑器中。 然后按 F5 键来运行代码。

VBA:查找和替换约会主题

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.运行代码后, 微软Outlook 弹出对话框。 点击 OK 按钮。

6.在第二 微软Outlook 对话框中,输入要替换的文本,然后单击 OK 按钮。

7.在第三 微软Outlook 对话框中,输入要替换的文本,然后单击 OK.

备注:如果只想删除指定日历中主题的所有“复制”字词,请将此框留空。

8。 点击 OK 在下面的对话框中单击按钮。

9.在 选择“文件夹” 对话框中,在指定的电子邮件帐户下选择日历,然后单击 OK 按钮。 看截图:

10.然后将弹出一个对话框,通知您更换成功。 请点击 OK 按钮。

11.然后,所选日历主题中的所有文本均已替换为新内容。


最佳办公生产力工具

Kutools for Outlook - 超过 100 种强大功能可增强您的 Outlook

🤖 人工智能邮件助手: 具有人工智能魔力的即时专业电子邮件——一键天才回复、完美语气、多语言掌握。轻松改变电子邮件! ...

📧 电子邮件自动化: 外出(适用于 POP 和 IMAP)  /  安排发送电子邮件  /  发送电子邮件时按规则自动抄送/密件抄送  /  自动转发(高级规则)   /  自动添加问候语   /  自动将多收件人电子邮件拆分为单独的消息 ...

📨 电子邮件管理: 轻松回忆电子邮件  /  按主题和其他人阻止诈骗电子邮件  /  删除重复的电子邮件  /  高级搜索  /  合并文件夹 ...

📁 附件专业版批量保存  /  批量分离  /  批量压缩  /  自动保存   /  自动分离  /  自动压缩 ...

🌟 界面魔法: 😊更多又漂亮又酷的表情符号   /  使用选项卡式视图提高 Outlook 工作效率  /  最小化 Outlook 而不是关闭 ...

👍 一键奇迹: 使用传入附件回复全部  /   反网络钓鱼电子邮件  /  🕘显示发件人的时区 ...

👩🏼‍🤝‍👩🏻 通讯录和日历: 从选定的电子邮件中批量添加联系人  /  将联系人组拆分为各个组  /  删除生日提醒 ...

超过 100特点 等待您的探索! 单击此处了解更多。

了解更多       免费下载      购买
 

 

Comments (8)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Many thanks. I think it is the 1st time, I copied and executed your macro "as is" without any error or any need for changes !
This comment was minimized by the moderator on the site
Buongiorno,
è possibile specificare la cartella posizione calendario (es.: \\mail@dominio\Calendario) senza far apparire la richiesta?
Grazie
Hi,
is it possible to specify the folder location calendar (ex .: \\ mail@domain\Calendar) without making the request appear?

Thank you


This comment was minimized by the moderator on the site
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.
This comment was minimized by the moderator on the site
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.
This comment was minimized by the moderator on the site
Worked fantastically! Thank you so much!!!
This comment was minimized by the moderator on the site
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)
This comment was minimized by the moderator on the site
Thank you! How can we modify it to always use the same calendar, and not show the first pop-up? thank you
This comment was minimized by the moderator on the site
Worked just fine really good It took me some time to understand that this is case sensitive, but that is very good. Thank you
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations