跳到主要內容

如何在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 for Applications 窗口。

3。 在裡面 Microsoft Visual Basic for Applications 窗口,雙擊以展開 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