使用 VBA 与团队会议起草 Outlook 日历邀请的最可靠方法?

问题描述 投票:0回答:0

我已经创建了一个 vba 模块来根据插入到 Excel 工作表中的数据起草日历邀请。为每一行插入的数据创建一个新的日历邀请。截至目前,一旦起草了日历邀请,用户就必须手动添加 Teams 会议。我希望在日历邀请中自动包含一个团队会议,如果可能的话,确保任何受邀的人都可以参加会议而不必被允许。

我的代码遵循与我在搜索解决方案时发现的这个片段非常相似的逻辑,但我没有包括它,因为它也有机密信息:

Sub setmeeting()

Dim O As Outlook.Application
Dim OAPT As Outlook.AppointmentItem

Set O = New Outlook.Application

Set OAPT = O.CreateItem(olAppointmentItem)
OAPT.MeetingStatus = olMeeting

With OAPT

    .RequiredAttendees = "[email protected]"
    .OptionalAttendees = "[email protected]"
    .Subject = "I Love VBA"
    .Start = "11/21/2019 12:00:00 PM"
    .End = "11/21/2019 12:30:00 PM"
    .Body = "Hello World"
    .Location = "Cubicle"
    .Display
    .Send

End With

Set OAPT = Nothing
Set O = Nothing
End Sub

我知道并尝试过 SendKeys 方法:

SendKeys "{F10}", True
'Switch to ribbon shortcuts
SendKeys "H", True
'Hit the Microsoft teams meetings button, requires teams to be installed
SendKeys "TM", True
'Now to add signature: Switch to meeting location button

但我知道 SendKeys 方法不是最可靠的,并且该程序每次在许多不同的设备上运行时都需要始终如一地工作。我还需要确保如果活动窗口以某种方式更改,它绝对不会影响其他应用程序。有没有更可靠的方法使用 VBA 将团队会议添加到 Outlook 日历邀请?

excel vba outlook microsoft-teams
© www.soinside.com 2019 - 2024. All rights reserved.