vba when saving to pdf how to define where it is saved code example

Example: Excel VBA PDF sheet and save to file path from cell

Sub GetFilePath_Click()

Dim FileAndLocation As Variant
Dim strPathLocation As String
Dim strFilename As String
Dim strPathFile As String
strPathLocation = Worksheets("05282017").Range("D3").Value
strFilename = Worksheets("05282017").Range("D2").Value
strPathFile = strPathLocation & strFilename
FileAndLocation = Application.GetSaveAsFilename _
(InitialFileName:=strPathLocation & strFilename, _
filefilter:="PDF Files (*.pdf), *.pdf", _
Title:="Select Folder and FileName to save")
'This is the concatenated value of selected folder location and filename
MsgBox FileAndLocation

 

End Sub

Tags:

Vb Example