Hi all new here but I am trying to create a button that will export and invoice to a PDF file that a user can name as they please. Currently the save as box comes up but regardless of what is typed it save it as the workbook name. Any and all help is appreciated. Code is below.
Private Sub CommandButton1_Click()
Dim sPath As String
Dim sFile As Variant
Dim ws As Worksheet
On Error GoTo ErrHandle
sPath = ThisWorkbook.Path & "" & "Quote" & Me.Range("g7")
sFile = Application.GetSaveAsFilename _
(InitialFileName:=sPath, _
FileFilter:="PDF Files (*.pdf), *.pdf", _
Title:="Select Folder and File Name to save")
If sFile = "False" Then
MsgBox ("Please Choose A File Name")
Exit Sub
End If
Me.ExportAsFixedFormat _
Type:=xlTypePDF, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
Exit Sub
ErrHandle:
MsgBox ("Document Not Saved")
End Sub
Private Sub CommandButton1_Click()
Dim sPath As String
Dim sFile As Variant
Dim ws As Worksheet
On Error GoTo ErrHandle
sPath = ThisWorkbook.Path & "" & "Quote" & Me.Range("g7")
sFile = Application.GetSaveAsFilename _
(InitialFileName:=sPath, _
FileFilter:="PDF Files (*.pdf), *.pdf", _
Title:="Select Folder and File Name to save")
If sFile = "False" Then
MsgBox ("Please Choose A File Name")
Exit Sub
End If
Me.ExportAsFixedFormat _
Type:=xlTypePDF, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
Exit Sub
ErrHandle:
MsgBox ("Document Not Saved")
End Sub