save and send worksheet as pdf

rosajen

New Member
Joined
Aug 10, 2011
Messages
1
Hi!!

I'm trying save the first sheet of my workbook as a pdf then attach to an outlook email then view the email before sending. Everything works except for getting the pdf to attach. My code is all activiated by the button click event. Range("T2") is the file path where it is saved. It's

="S:\Common\MANUALS\QUALITY\IS\Notes\Furnace Notes"&TEXT(H1,"mmddyy")

the part of the code in bold seems to be the only part not working. I'm using excel 2007

Please help!! thanks
smile.gif


Option Explicit
Sub SaveBtn_Click()
Dim filename As String
ThisFile = Range("T2").Value
With ActiveSheet
.ExportAsFixedFormat _
Type:=xlTypePDF, _
filename:=ThisFile, _
OpenAfterPublish:=True
End With
Mail
End Sub

Sub Mail()
Dim filename As String
RDB_Mail_PDF_Outlook filename, "name@email.com", "Furnace Notes and Summary" & Range("H1"), "This is a summary of today's meeting" & vbNewLine & vbNewLine & "My name", False
End Sub

Function RDB_Mail_PDF_Outlook(filenamepdf As String, StrTo As String, StrSubject As String, StrBody As String, Send As Boolean)
Dim OutApp As Object
Dim OutMail As Object

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
.To = StrTo
.CC = ""
.BCC = ""
.Subject = StrSubject
.Body = StrBody
.Attachments.Add filenamepdf
.Display
End If
End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing
End Function
<!-- / message -->
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Hello and welcome to The Board.
Code:
Sub Mail()
Dim filename As String
RDB_Mail_PDF_Outlook filename, "name@email.com", "Furnace Notes and Summary" & Range("H1"), "This is a summary of today's meeting" & vbNewLine & vbNewLine & "My name", False
End Sub
In the above you are declaring 'filename' and passing it to the function without setting a value.
 
Upvote 0

Forum statistics

Threads
1,224,551
Messages
6,179,473
Members
452,915
Latest member
hannnahheileen

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