ActiveSheet.ExportAsFixedFormat set file path

frankortizmachalert

New Member
Joined
Jul 11, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I am using the following code and works as expected but when it creates the PDF and opens the save location is 'Documents' but I want it to save to same folder location that the open worksheet is from.

Sub print_shipping_tabs()
'
' print_shipping_tabs Macro
' Prints the Shipping Tabs Only
'
'
Sheets(Array("Shipping", "Shipping (CO1)", "Shipping (CO2)", "Shipping (CO3)", "Shipping (CO4)", "Shipping (CO5)", "Shipping (CO6)", "Shipping (CO7)", "Shipping (CO8)", "Shipping (CO9)")).Select
Sheets("Shipping").Activate
'Save Active Sheet(s) as PDF
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Worksheets("Job Notice").Range("S1"), Quality:=xlQualityStandard, _
IncludeDocProperties:=False, IgnorePrintAreas:=False, OpenAfterPublish:=True
Sheets("Job Notice").Activate
End Sub
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
I want it to save to same folder location that the open worksheet is from.

VBA Code:
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=ActiveWorkbook.Path & "\" & Worksheets("Job Notice").Range("S1"), Quality:=xlQualityStandard, _
   IncludeDocProperties:=False, IgnorePrintAreas:=False, OpenAfterPublish:=True
 
Upvote 0
Solution

Forum statistics

Threads
1,224,826
Messages
6,181,192
Members
453,021
Latest member
pingpong7117

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