I have this VBA that sends an email based on cell change and attaches the file. I don't want it to attach the file. I want it to attach a LINK to file. This will be used for both OneDrive and SharePoint files.
Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range) Dim xRgSel As Range Dim xOutApp As Object Dim xMailItem As Object Dim xMailBody As String On Error Resume Next Application.ScreenUpdating = False Application.DisplayAlerts = False Set xRg = Range("D2:D50") Set xRgSel = Intersect(Target, xRg) ActiveWorkbook.Save If Not xRgSel Is Nothing Then Set xOutApp = CreateObject("Outlook.Application") Set xMailItem = xOutApp.CreateItem(0) xMailBody = "Cell(s) " & xRgSel.Address(False, False) & _ " in the worksheet '" & Me.Name & "' were modified on " & _ Format$(Now, "mm/dd/yyyy") & " at " & Format$(Now, "hh:mm:ss") & _ " by " & Environ$("username") & "." With xMailItem .To = "XXX@XXX.com" .Subject = "Worksheet modified in " & ThisWorkbook.FullName .Body = xMailBody .Attachments.Add (ThisWorkbook.FullName) .Display End With Set xRgSel = Nothing Set xOutApp = Nothing Set xMailItem = Nothing End If Application.DisplayAlerts = True Application.ScreenUpdating = True