Email questions vba

Noz2k

Well-known Member
Joined
Mar 15, 2011
Messages
693
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

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
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Thnaks, Haven't fully tried to link yet, as I'm not working with outlook. But will take a look and try and tweak my code accordingly.

The fileformat:=51 doesn't seem to prevent the prompt though
 
Upvote 0

Forum statistics

Threads
1,224,540
Messages
6,179,417
Members
452,912
Latest member
alicemil

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