Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro Using Send Receipent with Attachment Excel Feature 1

Status
Not open for further replies.

DrMingle

Technical User
May 24, 2009
116
0
0
US
I want to be able to use the exact feature in Excel for send receipent (with attachment): --> I don't want to have a predefined email address in the macro...I want the TO: field to be empty. I will be assigning this macro to a button within the current spread sheet.

The end goal is to get the activeworksheet as an attachment in an email with the subject line being the same as the activeworksheet and the TO: field is to remain empty.

Below is the code I currently have:

Sub Mail_workbook_1()
Dim wb As Workbook
Set wb = ActiveWorkbook

If Val(Application.Version) >= 12 Then
If wb.FileFormat = 51 And wb.HasVBProject = True Then
MsgBox "There is VBA code in this xlsx file, there will" & vbNewLine & _
"be no VBA code in the file you send. Save the" & vbNewLine & _
"file first as xlsm and then try the macro again.", vbInformation
Exit Sub
End If
End If

On Error Resume Next
wb.SendMail "drmingle@example.com", _
"ActiveWorkbook"
On Error GoTo 0
End Sub
 
Try

[RED]Application.Dialogs(xlDialogSendMail).Show[/RED]

instead of wb.SendMail

The filename will be in the SUBJECT: field and the TO: field will be blank.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top