Skip to main content

Outlook:作為會議組織者,如何在日曆中保留已取消的會議?

Author: Sun Last Modified: 2025-05-12

在 Outlook 中,作為會議組織者,當您取消會議時,該會議將自動從日曆中刪除。在某些情況下,您可能希望將已取消的會議保留在日曆中以進行一些標記。然而,Outlook 中並沒有內建功能可以處理這項工作。本教程提供了兩個 VBA 程式碼,在取消會議的同時將其保留為約會。

用於將已取消會議複製為約會的 VBA 程式碼


用於將已取消會議複製為約會的 VBA 程式碼

以下是兩個程式碼,可以在取消會議的同時將其複製並粘貼為約會。

注意:在啟用程式碼之前,請確保這兩個選項已勾選:

啟用 Outlook,點擊 文件 > 選項,在 Outlook 選項窗口中,點擊 信任中心 標籤,然後點擊 信任中心設置,接著在信任中心窗口中,點擊 宏設置 標籤,勾選 啟用所有宏(不推薦;可能執行危險代碼) 將宏安全設置應用於已安裝的外掛程式 選項。點擊 確定 > 確定 關閉窗口。重新啟動 Outlook。

doc keep meeting in calendar 1
doc keep meeting in calendar 2

1. 切換到 Outlook 日曆檢視,並選擇要取消的會議。按下 Alt + F11 鍵以啟用 Microsoft Visual Basic for Applications 窗口。

2. 點擊 插入 > 模組 以插入一個新的空白模組。然後將以下程式碼複製並粘貼到其中。

程式碼:將會議複製為約會並取消它

Sub CopyMeetingAsAppointmentBeforeCancel()
'UpdatebyExtendoffice20221129
Dim xAppointmentItem As AppointmentItem
Dim xMeetingItem As AppointmentItem
On Error Resume Next
Set xMeetingItem = GetCurrentItem()
Set xAppointmentItem = Application.CreateItem(olAppointmentItem)
With xAppointmentItem
  .Subject = "Canceled: " & xMeetingItem.Subject
  .Start = xMeetingItem.Start
  .Duration = xMeetingItem.Duration
  .Location = xMeetingItem.Location
  .Body = xMeetingItem.Body
  .Save
  .Move Application.ActiveExplorer.CurrentFolder
End With
With xMeetingItem
  .MeetingStatus = olMeetingCanceled
  .Send
  .Delete
End With
Set xAppointmentItem = Nothing
Set xMeetingItem = Nothing
End Sub

Function GetCurrentItem() As Object
  On Error Resume Next
  Select Case TypeName(Application.ActiveWindow)
    Case "Explorer"
      Set GetCurrentItem = Application.ActiveExplorer.Selection.Item(1)
    Case "Inspector"
      Set GetCurrentItem = Application.ActiveInspector.CurrentItem
  End Select
End Function
doc keep meeting in calendar 3

3. 點擊 執行 按鈕或按下 F5 鍵,現在所選的會議已被取消,並且出現了一個名為 已取消 & 主題 的新約會。

doc keep meeting in calendar 4

如果您想將會議複製並粘貼為另一個日曆中的約會,然後取消該會議,請使用以下程式碼:

程式碼:將會議複製為另一個日曆中的約會並取消它

Sub CopyMeetingAsAppointmentToCalenderBeforeCancel()
'Updatebyextendoffice20221129
Dim xDestCalendar As Outlook.MAPIFolder
Dim xNameSpace As Outlook.NameSpace
Dim xAppointmentItem As AppointmentItem
Dim xMeetingItem As AppointmentItem
On Error Resume Next
Set xNameSpace = Application.GetNamespace("MAPI")
Set xDestCalendar = xNameSpace.PickFolder
If xDestCalendar.DefaultItemType <> olAppointmentItem Then
  MsgBox "Please Select calendar folder. ", vbOKOnly + vbInformation, "Kutools for Outlook"
  Exit Sub
End If
Set xMeetingItem = GetCurrentItem()
Set xAppointmentItem = Application.CreateItem(olAppointmentItem)
With xAppointmentItem
  .Subject = "Canceled: " & xMeetingItem.Subject
  .Start = xMeetingItem.Start
  .Duration = xMeetingItem.Duration
  .Location = xMeetingItem.Location
  .Body = xMeetingItem.Body
  .Save
  .Move xDestCalendar
End With
With xMeetingItem
  .MeetingStatus = olMeetingCanceled
  .Send
  .Delete
End With
Set xDestCalendar = Nothing
Set xNameSpace = Nothing
Set xAppointmentItem = Nothing
Set xMeetingItem = Nothing
End Sub

Function GetCurrentItem() As Object
  On Error Resume Next
  Select Case TypeName(Application.ActiveWindow)
    Case "Explorer"
      Set GetCurrentItem = Application.ActiveExplorer.Selection.Item(1)
    Case "Inspector"
      Set GetCurrentItem = Application.ActiveInspector.CurrentItem
  End Select
End Function

點擊 執行 按鈕或按下 F5 鍵,彈出 選擇文件夾 對話框,讓您選擇一個日曆文件夾來粘貼該約會,然後點擊 確定。

doc keep meeting in calendar 5

現在,該會議已被取消,並且已複製並粘貼為您選擇的日曆文件夾中的約會。

doc keep meeting in calendar 6