Saving excel sheet into a .PDF using macro.

Luke1690

Board Regular
Joined
Jul 26, 2022
Messages
121
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi All,

i want to save a excel sheet call ("Mon") in a specific location with a file name picked form a range.

i used the below code to do this and it worked fine once. Now it saves it into my documents instead of the file location.

Sub SaveActiveSheetsAsPDF()

'Create and assign variables
Dim saveLocation As String
saveLocation = "EnterLocationHeref"

'Save Active Sheet(s) as PDF
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=Sheets("mon").Range("ac3").Value
End Sub

Can anyone tell me where I'm going wrong?

Thanks Guys
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
I don't see saveLocation in the Filename.
something like:
VBA Code:
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
    Filename:=saveLocation & "\" & Sheets("mon").Range("ac3").Value
 
Upvote 0
Solution
I don't see saveLocation in the Filename.
something like:
VBA Code:
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
    Filename:=saveLocation & "\" & Sheets("mon").Range("ac3").Value
Thanks Bob,

worked Perfect
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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