Hi.
Looking for VBA code to save the print area to a new excel document and to be prompted for the file path.
I have PDF sorted but can’t seem to get to export to excel document.
Thanks.
Looking for VBA code to save the print area to a new excel document and to be prompted for the file path.
I have PDF sorted but can’t seem to get to export to excel document.
Thanks.
Code:
Private Sub CommandButton8_Click()
Dim sPath As String
Dim sFile As Variant
Dim ws As Workbook
On Error GoTo ErrHandle
sPath = ThisWorkbook.Path & "\" & ThisWorkbook.Sheets("BH1").Range("G10")
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
ActiveWorkbook.ExportAsFixedFormat _
Type:=x1typePDF, _
Filename:=sFile, _
Quality:=q1qualitystandard, _
Includedocproperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
Exit Sub
ErrHandle:
MsgBox ("Document Not Saved")
End Sub