'Export to PDF and Prompt User for Folder Path and File Name to Save

I can't figure out how to prompt the user for a folder path and the save name. Below is the code I have gotten to work.

Sub PrintToPDF

ThisWorkbook.Sheets("Sheet 1","Sheet 3").Select

ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePdf, _
Filename:="test.pdf", 
Quality:=xlQualityStandard, _
IncludeDocumentProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True

Sheets("Sheet 1").Select

End Sub

Thanks for the help!



Solution 1:[1]

The code below will prompt the user to select a location and filename to save the pdf as.

Dim file_name As Variant
file_name = Application.GetSaveAsFilename(FileFilter:="Adobe PDF File_ (*.pdf), *.pdf")

If file_name <> False Then
  ActiveWorkbook.SaveAs Filename:=file_name
  MsgBox "File Saved!"
End If

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 APW