I have the following code that will save an excel sheet as a PDF to the desktop by default. I would like to specify the folder that it will save to. The folder I need to save to, which may change is, C:\Users\User1\Desktop\Work.
Thank you!
Thank you!
VBA Code:
Function Save_PDF() As Boolean ' Copies sheets into new PDF file
Dim Thissheet As String, ThisFile As String, PathName As String
Dim SvAs As String
Application.ScreenUpdating = False
' Get File Save Name
Thissheet = ActiveSheet.Name
ThisFile = ActiveWorkbook.Name
PathName = ActiveWorkbook.Path
SvAs = PathName & "\" & Thissheet & "_" & Format(Date, "yyyy-mm-dd") & ".pdf"
'Set Print Quality
On Error Resume Next
ActiveSheet.PageSetup.PrintQuality = 800
Err.Clear
On Error GoTo 0
' Instruct user how to send
On Error GoTo RefLibError
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=SvAs, Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=False, OpenAfterPublish:=True
On Error GoTo 0
SaveOnly:
MsgBox "A copy of this sheet has been successfully saved as a .pdf file: " & vbCrLf & vbCrLf & SvAs & _
"Review the .pdf document. If the document does NOT look good, adjust your printing parameters, and try again."
Save_PDF = True
GoTo EndMacro
RefLibError:
MsgBox "Unable to save as PDF. Reference library not found."
Save_PDF = False
EndMacro:
End Function