PDA

View Full Version : Edit URL in meeting hyperlink (MS Teams meeting)



mooneym3
03-19-2020, 02:50 PM
Hello everyone,

I have never written VBA in Outlook (only Excel), I have looked and could not find an answer to, what I believe may be a simple solution. I know enough I could have altered a similar code, but found nothing similar (for Outlook this would be easy in Excel).

I need a macro that will replace any hyperlinks in meetings from "https://teams.Microsoft.com/BlaBlaBla" with "mteams://teams.microsoft.com/BlaBlaBla" (Change 'https' to 'msteams')

Currently the URL in a Teams meeting opens a web site/app, I have to select "open in desktop app", and the internet tab doesn't close... Changing https to msteams opens the meeting directly in the desktop app.

I don't want to manually edit every meeting I send. The fact the current link opens a web page that does not close after launching the desktop app, leaves me with a bunch of tabs open on a busy day

Sorry I have no code of my own but this is a top complaint on MS support site - many could benefit from this...

gmayor
03-19-2020, 10:20 PM
I cannot test this without the source material, but something along the lines of the following should help point the way.


Sub Macro1()
Dim olMeeting As Object
Dim olInsp As Outlook.Inspector
Dim wdDoc As Object
Dim oLink As Object
Dim strAddress As String

On Error Resume Next
Select Case Outlook.Application.ActiveWindow.Class
Case olInspector
Set olMeeting = ActiveInspector.currentItem
Case olExplorer
Set olMeeting = Application.ActiveExplorer.Selection.Item(1)
End Select

If TypeName(olMeeting) = " MeetingItem" Then
With olMeeting
Set olInsp = .GetInspector
Set wdDoc = olInsp.WordEditor
For Each oLink In wdDoc.Range.hyperlinks
strAddress = oLink.Address
If LCase(strAddress) = "https://teams.microsoft.com/blablabla" Then
strAddress = "mteams://teams.microsoft.com/BlaBlaBla"
'MsgBox strAddress
oLink.Address = strAddress
oLink.TextToDisplay = strAddress 'or whatever
End If
Next oLink
olMeeting.Save
End With
End If
lbl_Exit:
Set olMeeting = Nothing
Set olInsp = Nothing
Set wdDoc = Nothing
Set oLink = Nothing
Exit Sub
End Sub