Excel to PDF - specific location saved by date

Crooks28

New Member
Joined
Sep 12, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi all

Ive had a look through the discussion board and cant quite find what i was looking for, or the codes were very different.
The idea is a macro button which saves to a specific location, saves as a PDF, saves name as todays date.
Please find code below.
Currently it is saving the PDF in the locations 1 file back, as the file name it is currently in, which is different to where I would like the output.
Any suggestions would be greatly appreciated.
Cheers

Private Sub SaveRangeAsPDF()
Dim PrintRng As Range
Dim SavePDF As String
Sheets("Week Review").Select
Set PrintRng = Range("B1:O127")
SavePDF = strPath
strPath = "L:\Mining\Underground\06.Dept General\Weekly Review" & Format(Now, "yyyy-mm-dd")
PrintRng.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=SavePDF, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Perhaps switch the order of these two lines?
VBA Code:
SavePDF = strPath
strPath = "L:\Mining\Underground\06.Dept General\Weekly Review" & Format(Now, "yyyy-mm-dd")
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,179
Members
452,615
Latest member
bogeys2birdies

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