e-mail subject name changing

G

Guest

hello all. ive been using the code below for some time now to send e-mails
when an assigned button is clicked (thanks RDeB) but now i need to make a
change. Part of my system adds worksheets to a final workbook, and this is
the one that is sent. Is it possible to write in to the macro so the name of
the workbook is changed to the name of the last copied worksheet? (save as?)
Or so the subject line of the e-mail contains the name of the copied
worksheet/s?

Sub MailOrder()
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 be no
VBA code in the file you send." & vbNewLine & _
"Save the file first as xlsm and then try the macro
again.", vbInformation
Exit Sub
End If
End If

On Error Resume Next
wb.SendMail "(e-mail address removed)", _
"Test Order e-mail"
On Error GoTo 0
End Sub

Thanks in advance, Andrew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top