0
在Outlook宏中使用AppointmentItem
上的Move
方法时,我失去了接收更新的能力,因为它正在创建项目的副本,而不是真正移动它。此行为导致该项目不再与原始链接关联,因此不会保留项目更新。Outlook VBA AppointmentItem.Move创建副本
我想通过VBA复制您获得的剪切/粘贴行为,它能够保持原始对象并且不会导致更新丢失。
我相信这与GlobalAppointmentID的基础上搜索周围,但我一直没能找到一种方法来实际移动约会。
我使用的代码如下。 GetFolderFromPath是一个辅助函数,用于从路径中返回一个文件夹对象,这非常合适。
Sub MoveItem()
Dim targetPath As String: targetPath = "\\[email protected]\Calendar\OOFS"
If Application.ActiveExplorer.Selection.Count = 0 Then
MsgBox ("No item selected")
Exit Sub
Else
Dim targetFolder As Outlook.Folder
Set targetFolder = GetFolderFromPath(targetPath)
For x = 1 To Application.ActiveExplorer.Selection.Count
Dim oSelected As Variant
Set oSelected = Application.ActiveExplorer.Selection.Item(x)
If oSelected.Class = olAppointment Then
Dim NS As NameSpace: Set NS = Application.GetNamespace("MAPI")
Dim oAppt As AppointmentItem: Set oAppt = NS.GetItemFromID(oSelected.EntryID)
oAppt.Move targetFolder
Set oAppt = Nothing
Set NS = Nothing
End If
Set oSelected = Nothing
Next x
Set targetFolder = Nothing
End If
End Sub
这是不正确的。因为如果我(在用户界面中)右键单击日历约会,选择剪切,然后将其粘贴到不同的日历文件夹中(或者只需简单地单击并将其拖动到不同的文件夹中),它将使用任何更新这是制作的。 – hdrpunk