Excel to pdf and mail

Tom1983

New Member
Joined
May 20, 2019
Messages
12
https://www.mrexcel.com/forum/gener...-code-convert-excel-pdf-email-attachment.htmlHi,

This is extension to the one thread paste here long time back.

It automticaly save and send mail via outlook but only issue is it saved whole excel file,where as we want only specific part of excel to be converted into pdf .

like we have so many tabs and we want pdf for one sepcific tab and then again specific cells or range

Not sure how to attach exce here..so plz assume tab name as Master and range (A1 toJ5).

Thank you
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
This saves the specified range as a PDF file:
Code:
    Dim PDFfile As String
    PDFfile = "C:\folder\path\PDF data.pdf" 'change as required
    Worksheets("Master").Range("A1:J5").ExportAsFixedFormat Type:=xlTypePDF, Filename:=PDFfile, _
        Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
Then use the PDFfile variable in the Outlook Attachments.Add line.
 
Upvote 0
Great thank you... Another issue... I want to give my name to pdf file instead of by default name of active workbook... How can I do that
 
Upvote 0
The PDFfile = line shows how to give the PDF a specific name. This must be a full name, including the folder path. If you want to create the PDF in the same folder as the active workbook then:
Code:
PDFfile = ActiveWorkbook.Path & "\PDF data.pdf"
 
Upvote 0
Yes i know PDffile=line where i need to make amendment but still not get what you have said above.....can we give a range to it...like PDFfile= Range("A3") something like this....plz suggest
 
Upvote 0
Assuming A3 on the active sheet contains the full file name, including folder path, then:
Code:
PDFfile = Range("A3").Value
Or if it contains just the file name then:
Code:
PDFfile = ActiveWorkbook.Path & "\" & Range("A3").Value
 
Upvote 0
I treid both ways but it is not working....I have given path name then file name and then what description i want for pdf but it is giving error.
Here is what iam typing incell A3 (C:\VFA05\Desktop\Appy\ALT Invoice file\Way terminal invoice)
 
Upvote 0
Yep, either add .pdf to the end of the A3 cell value or:
Code:
PDFfile = Range("A3").Value & ".pdf"
 
Upvote 0

Forum statistics

Threads
1,223,693
Messages
6,173,866
Members
452,536
Latest member
Chiz511

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