vba to send sheet as pdf in outlook with subject that is in a1

lpratt

New Member
Joined
Aug 6, 2010
Messages
22
simple i know but i cannot work this out.

I want to button that will attach current sheet named template as a pdf to a outlook email
There are no set recipients this will be entered in Outlook
Subject line will be what is in cell a1

that is it
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Try this:

VBA Code:
Sub MailActiveSheet()
  Dim wPathFile As String
  
  wPathFile = ThisWorkbook.Path & "\template.pdf"
  ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:=wPathFile, _
    Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False

  With CreateObject("Outlook.Application").CreateItem(0)
    .To = ""
    .Subject = ActiveSheet.Range("A1").Value
    .Body = ""
    .Attachments.Add wPathFile
    .Display
  End With
End Sub

🤗
Regards
Dante Amor
 
Upvote 0
Hi Dante

How do you change the file name? And is is posible to add a signature to the mail?

Brgds
René
 
Upvote 0
If you have a signature block setup in Outlook it will be added to the new email or if you have several you can select the correct one once the email is displayed. As far as the file name does this come from a cell in Excel or do you want to add a name via another method like an input box?
 
Upvote 0

Forum statistics

Threads
1,215,137
Messages
6,123,254
Members
449,093
Latest member
Vincent Khandagale

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