.
This works on a PC .. not certain about a Mac :
Option Explicit
Sub test()
Dim TempWB As Workbook
Dim fd As String
Application.DisplayAlerts = False
Application.ScreenUpdating = False
ActiveSheet.Copy
Set TempWB = ActiveWorkbook
fd = "C:\Users\My\Desktop" 'Edit path as required. Assumes the folder Test already exists on the desktop
'fd now holds the path to the folder
With TempWB
'Exchange Sheet is the name of the saved CSV file. Edit name as required.
.SaveAs Filename:=fd & "\Exchange_Sheet", FileFormat:=xlCSVWindows, CreateBackup:=False
.Close
End With
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Email_Sheet
End Sub
Sub Email_Sheet()
Dim oApp As Object
Dim oMail As Object
Dim CSVSheet As String
'Turn off screen updating
Application.ScreenUpdating = False
'Copy the active worksheet and save to a temporary workbook
'ActiveSheet.Copy
CSVSheet = "C:\Users\My\Desktop\Exchange_Sheet.csv"
'Create a temporary file in your current directory that uses the name
' of the sheet as the filename
'LFileName = LWorkbook.Worksheets(1).Name
On Error Resume Next
'Delete the file if it already exists
'Kill LFileName
On Error GoTo 0
'Save temporary file
'LWorkbook.SaveAs Filename:=LFileName
'Create an Outlook object and new mail message
Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.CreateItem(0)
'Set mail attributes (uncomment lines to enter attributes)
' In this example, only the attachment is being added to the mail message
With oMail
.To = ""
.Subject = ""
.body = ""
.Attachments.Add CSVSheet
.Display
End With
'Turn back on screen updating
Application.ScreenUpdating = True
Set oMail = Nothing
Set oApp = Nothing
End Sub
Bookmarks