In a previous post, SE'er harrymc suggested this line to my code so that the user is allowed to name the file but the directory save path is fixed.
strfile = "C:\mypath\Selection_" & Format(Now(), "yyyymmdd_hhmmss") & ".pdf"
I incorporated the above code but the save directory still defaults to \This PC\Documents.
I have spent several hours reading various SE and other VBA forums but have not found a solution. Your expertise is much appreciated.
Sub PrintSelectionToPDF() 'SUBROUTINE: PrintSelectionToPDF 'DEVELOPER: Ryan Wells 'DESCRIPTION: Print your currently selected range to a PDF Dim ThisRng As Range Dim strfile As String Dim myfile As Variant If Selection.Count = 1 Then Set ThisRng = Application.InputBox("Select a range", "Get Range", Type:=8) Else Set ThisRng = Selection End If 'Prompt for save location strfile = "C:\Users\DJB Laptop\OneDrive .....\_Qualtrics\_2019-2020\2019-20 2nd Semester\Quant PDF Dump\\Selection_" & Format(Now(), "yyyymmdd_hhmmss") & ".pdf" '"C:\Users\DJB Laptop\OneDrive - Albany County School District One\_Qualtrics\_2019-2020\2019-20 2nd Semester\Quant PDF Dump\" & Format(Now(), "yyyymmdd_hhmmss") & ".pdf" _ myfile = Application.GetSaveAsFilename _ (InitialFileName:=strfile, _ FileFilter:="PDF Files (*.pdf), *.pdf", _ Title:="Select Folder and File Name to Save as PDF") If myfile <> "False" Then 'save as PDF ThisRng.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ myfile, Quality:=xlQualityStandard, IncludeDocProperties:=True, _ IgnorePrintAreas:=False, OpenAfterPublish:=True Else MsgBox "No File Selected. PDF will not be saved", vbOKOnly, "No File Selected" End If End Sub