How to get Microsoft Teams meeting URL by using VBA

PEI Simon (CI/PIO4) 0 Reputation points
2023-04-06T06:53:26.05+00:00

teams url

I want to use excel VBA code to create a TEAMS meeting and get the URL of the meeting to the excel worksheet. My code as below.


Sub GetTeamsMeetingLink()
    Dim oApp As Object
    Dim oMeeting As Object
    Dim strMeetingLink As String
    
    Set oApp = CreateObject("Outlook.Application")
    Set oMeeting = oApp.CreateItem(olAppointmentItem)
    
    
    'set meeting info
    With oMeeting
        .Subject = "TEST"
        .RequiredAttendees = "******@TEST.COM"
        .Start = (Now)
        .Duration = 60
        .Body = "TEST"
        .Location = "Microsoft Teams"
        
        'add teams meeting info
        .NetMeetingType = olMeeting
    End With
    
    'showup meeting
    oMeeting.Display
    
    SendKeys "%h", True
    SendKeys "TM", True
        

    'get URL in the meeting
    strMeetingLink = oMeeting.GetAssociatedAppointment(False).NetMeetingUrl
    Debug.Print strMeetingLink

    Set oMeeting = Nothing
    Set oApp = Nothing
    
    
End Sub

but there was showing up an error at

oMeeting.GetAssociatedAppointment(False).NetMeetingUrl

Hope to get help here!

Outlook | Windows | Classic Outlook for Windows | For business
Microsoft 365 and Office | Excel | For business | Windows
Microsoft Teams | Microsoft Teams for business | Other
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.