Macro to create and attach pdf

CycloneBill

New Member
Joined
Aug 28, 2013
Messages
2
Good Morning All,

I am attempting to make a macro that will create a pdf, then attach it to Outlook email. I have succeeded in getting it to, create, address correctly but not attach the pdf. Below is my script:

Dim SheetName As String
SheetName = ActiveSheet.Name


ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"T:\Accounting\MAsters and Projections\Payroll master schedules\Outbound Masters\" & ActiveSheet.Name, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
True


Dim OutApp As Object
Dim OutMail As Object


Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
With OutMail
.To = Workbooks("UploadMacro.xlsm").Worksheets("Ref").Range("F3")
.CC = Workbooks("UploadMacro.xlsm").Worksheets("Ref").Range("F2")
.BCC = ""
.Subject = ActiveSheet.Name
.Body = ""
.Attachments.Add ActiveWorkSheet.FullName <---- This is where I am hitting a wall
.Display






End With




End With


End Sub

Advise? Thanks in advance!
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Welcome to the Board!

Does this work?

Rich (BB code):
Dim SheetName As String
SheetName = ActiveSheet.Name


ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"T:\Accounting\MAsters and Projections\Payroll master schedules\Outbound Masters\" & SheetName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
True


Dim OutApp As Object
Dim OutMail As Object


Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
With OutMail
.To = Workbooks("UploadMacro.xlsm").Worksheets("Ref").Range("F3")
.CC = Workbooks("UploadMacro.xlsm").Worksheets("Ref").Range("F2")
.BCC = ""
.Subject = ActiveSheet.Name
.Body = ""
.Attachments.Add "T:\Accounting\MAsters and Projections\Payroll master schedules\Outbound Masters\" & SheetName & ".pdf"
.Display






End With




End With


End Sub
 
Upvote 0

Forum statistics

Threads
1,214,424
Messages
6,119,400
Members
448,893
Latest member
AtariBaby

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