Save excel file to pdf

Khalid_exel

New Member
Joined
Jul 17, 2022
Messages
3
Office Version
  1. 2016
Platform
  1. Windows
I use this code:
VBA Code:
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Left(ActiveWorkbook.FullName, InStrRev(ActiveWorkbook.FullName, ".")) & "pdf", _
        Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=True, OpenAfterPublish:=False
to save file to pdf in the same folder
my question
I want to save the PDF file with a name similar to a cell in the sheet
can any one help me to do that ?
thanks
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
What do you mean "similar to"--not exactly? Which cell, which sheet?

Can you give an example of what is in the cell, and what you want the file name to be?

Something like this:

Rich (BB code):
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=ThisWorkbook.Path & "\" & Worksheets("Sample").Range("A1") & ".pdf", _
        Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=True, OpenAfterPublish:=False
 
Upvote 0
Solution
What do you mean "similar to"--not exactly? Which cell, which sheet?

Can you give an example of what is in the cell, and what you want the file name to be?

Something like this:

Rich (BB code):
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=ThisWorkbook.Path & "\" & Worksheets("Sample").Range("A1") & ".pdf", _
        Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=True, OpenAfterPublish:=False
The code I attached saves the excel file with the same name but in the pdf format

I need to save the file with a name matches text in a cell
Example:
The text in cell A3 "eric"
The file is saved as: eric.PDF
sorry for my language :)
 
Upvote 0
Could you just add to the saved filename?

& Format(Now(), " DD.MM.YY hh.mm.ss"
 
Upvote 0

Forum statistics

Threads
1,214,551
Messages
6,120,156
Members
448,948
Latest member
spamiki

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