Hi,
Looking for VBA to save all sheets to PDF. Currently i have the below, but only saves the active sheet.
Thanks.
Looking for VBA to save all sheets to PDF. Currently i have the below, but only saves the active sheet.
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("Sheet1").Range("G10") & " - Test name"
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:=x1typePDF, _
Filename:=sFile, _
Quality:=q1qualitystandard, _
Includedocproperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
Exit Sub
ErrHandle:
MsgBox ("Document Not Saved")
End Sub