【发布时间】:2021-07-29 00:09:07
【问题描述】:
我正在尝试创建一键式解决方案,以拒绝并删除我们团队中的人员发出的所有“我从下午 2 点到下午 3 点我是 AFK”的会议请求(这会阻止每个人的日历)。
想法是创建一个宏,该宏将拒绝当前选择的会议请求并将其删除而无需任何提示。
Sub DeclineAndDelete()
Dim cAppt As AppointmentItem
Set cAppt = Application.ActiveExplorer.Selection.Item(1).GetAssociatedAppointment(True)
MsgBox cAppt.Subject
Dim oResponse As MeetingItem
Set oResponse = cAppt.Respond(olMeetingDeclined, False)
oResponse.Delete ' <---- oResponse is set to Nothing'
cAppt.Delete
MsgBox "Ho"
Set cAppt = Nothing
Set oResponse = Nothing
End Sub
当我在收件箱中选择会议请求并运行宏时,它会弹出一个消息框,其中包含我选择的会议请求的主题 (MsgBox cAppt.Subject)。但是在调试时它显示cAppt.Respond 返回了Nothing。
MsgBox "Ho" 永远不会弹出。
为此,我尝试将olMeetingDeclined 更改为olMeetingAccepted,但没有任何区别。
我确实读过这个Auto-Decline Meeting Invite Run-Time Error 91: Object variable or With block variable not set,但根据文档Respond is supposed to return,这不是Nothing。
编辑:当会议组织者要求不回复时,cAppt.Respond() 似乎返回了Nothing。
在请求/允许响应的其他情况下,宏实际上可以正常工作!
【问题讨论】: