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?
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.
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