I have code that creates an outlook meeting request and it is working great. I want to be able to make this meeting request a Microsoft Teams Meeting. I cannot find any notes online on the objects to use for this and cannot find any objects in Outlook VBA that look like they will work. Does anyone know how to programmatically add Microsoft Teams to a meeting request?
-
You can copy the link to the Team Channel and include it in the email, eg: https://teams.microsoft.com/l/channel/... otherwise it's not clear what you're asking. Can you google: "MS teams api get team channel" .... https://learn.microsoft.com/en-us/graph/api/channel-get?view=graph-rest-1.0&tabs=http – Jeremy Thompson Jul 17 '20 at 05:35
-
what do you mean by " add Microsoft Teams to a meeting request"? – Subhasish Jul 17 '20 at 07:13
-
When you have Microsoft teams installed on a Windows 10 machine and the plugin installed in outlook (which happens when Team is installed), you have an option when creating a meeting to make it a Microsoft Teams meeting. That adds a link in the email to open the meeting in Teams). I want to programmatically add the Teams information. It is just a click of the button in the UI of Outlook. – LtlBear Jul 19 '20 at 04:11
2 Answers
The easiest way to run the command on the ribbon programmatically. You just need to know the idMso
value of the built-in command. The ExecuteMso
method of the CoommandBars class is useful in cases where there is no object model for a particular command. Works on controls that are built-in buttons
, toggleButtons
, and splitButtons
. On failure, it returns E_InvalidArg
for an invalid idMso
, and E_Fail
for controls that are not enabled or not visible.
But we deal with an add-in, so their idMso
values are not disclosed. In that case your option is to use Accessibility API, see Microsoft Active Accessibility for more information. Microsoft Active Accessibility is a Component Object Model (COM)-based technology that improves the way accessibility aids work with applications running on Microsoft Windows. It provides dynamic-link libraries that are incorporated into the operating system as well as a COM interface and API elements that provide reliable methods for exposing information about UI elements.
As the last resort, you may consider using Windows API function to click the button programmatically.
P.S. You may find the Are the command codes for ExecuteMso documented? page helpful.

- 47,483
- 3
- 24
- 45
-
Thanks for the suggestions. Unfortunately as best I can tell the Microsoft Teams button does not have a idMso value that can be used and I don't see anything that helps me use the Microsoft Active Accessibility in VBA. – LtlBear Jul 27 '20 at 23:28
You can use this code
Sub teammetting()
Dim nm As Outlook.AppointmentItem
Set nm = Application.CreateItem(olAppointmentItem)
nm.MeetingStatus = olMeeting
nm.Subject = "Subject"
nm.Start = 'format:DD/MM/YYYY HH:MM:SS AM/PM
nm.End =""'format:DD/MM/YYYY HH:MM:SS AM/PM
nm.requiredattendees "mail address of the invitees"
nm.Body = "Set the body of the email"
'Show the meeting
nm.Display
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
end sub
'use this code and try as there isn't any note of objects or

- 23,254
- 14
- 71
- 91
-
When you post code, you can highlight the code with `{}` or by indenting the code four spaces, otherwise it comes out a reflowable text. – AlBlue Dec 13 '20 at 20:06