Using VBA to open an Outlook window and put hyperlinks in the Body.

Gafftape

New Member
Joined
Apr 10, 2019
Messages
6
Two questions for this one.

First question:
I have this code that I’ve been messing with. I have it displaying my message the way that I want, but I would like two parts of it to be Hyperlinks.

Code:
Sub Workbook_AfterSave(ByVal Success As Boolean)


    If Success Then


        Dim OutApp As Object
        Dim OutMail As Object
        Dim strbody As String
        
'added these 2 variables
        Dim WinFilePath As String
        Dim MacFilePath As String
        


        Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(0)


'This is the location on the server where the Road Support form is located.
        WinFilePath = "\\FILESERVERXX\Shared\RTR"


'This is the same loaction as WinFilePath but formatted for Mac users.
        MacFilePath = "smb:\\FILESERVERXX\Shared\RTR"


'Edit "strbody" to change the E-mail message
        strbody = "Hello there! - The Road Support Form has been updated by " & Environ("USERNAME") & " at " & Format(Now(), "ddd dd mmm yy hh:mm") & vbCr & vbCr & "The updated file can be found at:" & vbCr & "For Windows Users: " & WinFilePath & vbCr & vbCr & "For Macitosh Users:" & MacFilePath




'Edit the recipients below.
        On Error Resume Next
        With OutMail
            .To = ""
            .Subject = "The Road Support form has been Updated" & " - " & Format(Now(), "ddd dd mmm yy")
            .Body = strbody
            .display
        End With


        On Error GoTo 0


        Set OutMail = Nothing
        Set OutApp = Nothing


    End If


End Sub

I want WinFilePath and MacFile Path to be Hyperlinks in the Email body.

Second question:

How can i get this to work in MacOS environment?
As is, MacOS won't allow for the creation of the Outlook Object.
My brief research on this says that I either:
Can't do this,
or i might be able to use an AppleScript.

Help on the First question and advice on the Second is much appreciated.

Thank you for you time.
-Gafftape
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Forum statistics

Threads
1,215,447
Messages
6,124,906
Members
449,194
Latest member
JayEggleton

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top