我发送Outlook 2016约会时,使用以下触发VBA代码:
Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
如何显示特定于“ AppointmentItem”类型的数据?
我希望有一个消息框“您想在学校谈论计算机”,
但出现运行时错误“ 438”。
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim prompt As String
prompt = "Do you want to talk about " & Item.Subject 'Works
prompt = prompt & " at " & Item.Location 'Error
If MsgBox(prompt, vbYesNo + vbQuestion, "Sample") = vbNo Then
Cancel = True
End If
End Sub
答案 0 :(得分:0)
如果您发送会议请求,则发送的项目本身是olMeetingRequest
而不是olAppoinmentItem
。
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim objAppointment As AppointmentItem
If Item.Class = olMeetingRequest Then
Set objAppointment = Item.GetAssociatedAppointment(False)
Debug.Print objAppointment.Subject
Debug.Print objAppointment.Location
End If
End Sub