trying to save excel sheets to pdf

daves37120

New Member
Joined
Apr 8, 2021
Messages
4
Office Version
  1. 2010
Platform
  1. Windows
Hi folks,

I have been working on a macro to save certain tabs in a workbook as pdf in a folder. So far it will select the tabs and create a pdf file, but for the life of me, I cannot determine how to get it to save to the folder. The pdf is named correctly when exported, but is not saved. Several macro variants have been tried and all are removed from the macro with the hope someone can show me the correct way to add it. The path is on a "Control" tab (all inputs are here). Any help would be greatly appreciated.

Sub SavePDF_2()
Dim Path, FileName1 As String
Path = Sheets("Control").Range("H13")
FileName1 = Sheets("Control").Range("H13")

ThisWorkbook.Sheets(Array("Management Discussion", "Operating Summary", "Subscription ARR", _
"Income Statement", "BS & Cash Flow", "Working Capital", "SG&A & FTE's")).Select

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:= _
Path & FileName1 & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=True


End Sub
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
What exactly is in H13 & why are you using it for both the path & filename?
 
Upvote 0
Good catch. It should be H16 and the path is: Path = Sheets("Control").Range("H16") 'C:\Dvinci Energy Inc\Test
 
Upvote 0
Is Test a folder or part of the file name?
 
Upvote 0
In that case you need to use
VBA Code:
Path & "\" & FileName1 & ".pdf"
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,415
Messages
6,119,382
Members
448,889
Latest member
TS_711

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