omagoodness
Board Regular
- Joined
- Apr 17, 2016
- Messages
- 59
I have a named print range on a sheet ("TipsPaid") that I want to save to pdf using VBA and command button. The code I am using (below) will select the range and open in a pdf document but does not save it to a file. I have been over 4 hours trying to figue out why it will not save. What am I doing wrong? I'm sure it is something simple but I don't see it. Please help.
VBA Code:
Option Explicit
Private Sub cmdSave_Click()
'declaring variables
'Setting range to be saved
Dim PRng As Range
Set PRng = Range("TipsPaid")
'path to save folder
Dim myPath As String
myPath = Application.ThisWorkbook.Path & "\" & "Tip-out Records"
'setting file name
Dim SDate As String, filename As String
SDate = Application.WorksheetFunction.Text(Cells(3, 17), "dd mmm yyyy")
filename = "Week Ending" & " " & SDate & ".pdf"
'Save Location
Dim SaveLocation As String
SaveLocation = myPath & " \ " & filename
'Save as pdf
PRng.ExportAsFixedFormat Type:=xlTypePDF, filename:= _
"SaveLocation", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
End Sub