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

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,969
Office Version
  1. 365
Platform
  1. Windows
What exactly is in H13 & why are you using it for both the path & filename?
 

daves37120

New Member
Joined
Apr 8, 2021
Messages
4
Office Version
  1. 2010
Platform
  1. Windows
Good catch. It should be H16 and the path is: Path = Sheets("Control").Range("H16") 'C:\Dvinci Energy Inc\Test
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,969
Office Version
  1. 365
Platform
  1. Windows
Is Test a folder or part of the file name?
 

daves37120

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

ADVERTISEMENT

Test is a folder
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,969
Office Version
  1. 365
Platform
  1. Windows
In that case you need to use
VBA Code:
Path & "\" & FileName1 & ".pdf"
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,969
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,130,342
Messages
5,641,592
Members
417,224
Latest member
llama9207

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
Top