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

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
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,215,206
Messages
6,123,639
Members
449,111
Latest member
ghennedy

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