Outlook has a macro that opens a link from a letter in Chrome and IE. This macro worked fine, but after reinstalling Windows 10 and Outlook 2016 it stopped (I copied the macro text through notepad). When you run the macro, the message "Compile error: Method or data member not found" appears in the line trURL = M.SubMatches (0) (SubMatches is highlighted).
Does anyone know how to fix this error?
Public Sub OpenLinks(olMail As Outlook.MailItem) Dim Reg1 As RegExp Dim M1 As MatchCollection Dim M As Match Dim strURL As String Dim oApp As Object Set oApp = CreateObject("InternetExplorer.Application") Set Reg1 = New RegExp With Reg1 .Pattern = "(https://example.com)" .Global = True .IgnoreCase = True End With If Reg1.Test(olMail.Body) Then Set M1 = Reg1.Execute(olMail.Body) For Each M In M1 strURL = M.SubMatches(0) Debug.Print strURL Shell """" & "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" & """" & " -new-tab " & strURL 'wait for page to load before passing the web URL Do While oApp.Busy DoEvents Loop oApp.navigate strURL oApp.Visible = True Next End If Set Reg1 = Nothing Set oApp = Nothing End Sub 'The following is a stub macro for testing the run a script rule without the need to send messages to trigger . Select a message and run the RunScript macro. Sub RunScript() Dim objApp As Outlook.Application Dim objItem As MailItem Set objApp = Application Set objItem = objApp.ActiveExplorer.Selection.Item(1) 'macro name you want to run goes here OpenLinks objItem End Sub