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

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
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,215,325
Messages
6,124,252
Members
449,149
Latest member
mwdbActuary

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