I have it set up so that I can email the activesheet on a button click, however I would also like to set it up so that it only emailed part of the sheet, as well as autocompleting the prompt which is raises to continue saving as a macro free workbook. Any ideas on how to do this wpuld be appreciated.
The prompt which comes up is
"The following features cannot be saved in macro-free workbooks:
-VB Project
To save a file with these features, click No, and then choose a macro-enabled filed type in the File Type List.
To continue saving as a macro-free workbook, click yes"
here is the code currently
The prompt which comes up is
"The following features cannot be saved in macro-free workbooks:
-VB Project
To save a file with these features, click No, and then choose a macro-enabled filed type in the File Type List.
To continue saving as a macro-free workbook, click yes"
here is the code currently
Rich (BB code):
Sub MailDetailed()
With Worksheets("Detailed")
.Visible = xlSheetVisible
.Activate
End With
Dim Recipient As String
Dim TempFilePath As String
Dim TempFileName As String
Recipient = Sheets("LookupLists").Range("E4").Value
TempFilePath = Environ$("temp") & "\"
TempFileName = "DetailedOutstanding " & Format(Now, "ddmmyyyy hhmm") & ".xlsx"
ActiveSheet.Copy
With ActiveWorkbook
.SaveAs Filename:=TempFilePath & TempFileName
.Close
End With
Dim objEmail ' Instantiated email object
intSpacing = 1 'The spacing between cells
intPadding = 3 'Spacing within a cell
borders_wanted = True 'True hides the cell edges and shows bordres
Set objEmail = CreateObject("CDO.Message")
objEmail.FROM = """Name""<automated@company.com>" 'From can take any form - Just name, just email or a combination"
objEmail.To = Recipient 'Email recipient
objEmail.Subject = "Fubject" 'Email Subject
objEmail.HTMLBody = "Please find the Subject attached.
#Note - This is an automatically generated email, please do not reply to this address"
objEmail.AddAttachment TempFilePath & TempFileName 'Option to add attachment to email
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = #
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "Config"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = #
objEmail.Configuration.Fields.Update
objEmail.Send
Kill TempFilePath & TempFileName
MsgBox "Email Sent To " & Recipient
End Sub