Hi everyone,
I'm using the below coding through listbox to create PDF - it's working fine. However I want sheet ("Home") to be PDF by default at all times regardless of selection in the listbox or not - is it possible ?
Thanks
I'm using the below coding through listbox to create PDF - it's working fine. However I want sheet ("Home") to be PDF by default at all times regardless of selection in the listbox or not - is it possible ?
Thanks
VBA Code:
Sub pdf_sh()
Dim i As Long, c As Long
Dim sheetarray() As String
With ActiveSheet.ListBoxSh
For i = 0 To .ListCount - 1
If .Selected(i) Then
ReDim Preserve sheetarray(c)
sheetarray(c) = .List(i)
c = c + 1
End If
Next i
End With
pdfName = Sheets("Home").Range("B9").Value & "_" & Sheets("Home").Range("B17")
ChDir "Test"
fileSaveName = Application.GetSaveAsFilename(pdfName, _
fileFilter:="PDF Files (*.pdf), *.pdf")
If fileSaveName <> False Then
Sheets(sheetarray()).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=fileSaveName, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
Worksheets("Home").Select
Exit Sub
End If
End Sub