I'm trying out some very simple code in Excel.
Sub PDF()
Path = "C:\users\MyName\Desktop\Name"
MsgBox (Path)
ThisWorkbook.Sheets(1).ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=Path, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
'
End Sub
This code works just fine, it exports the first tab as an excel document. However, what I want is for it to be able to export multiple sheets as a single PDF. So I tried this thinking it would work:
ThisWorkbook.Sheets(1,2,3).ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=Path, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
And that didn't work. I also tried:
ThisWorkbook.Sheets(array(1,2,3,4)).ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=Path, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
I've seen a few suggestions that suggest using
Array("Sheet1", "Sheet2")
However I do not want to use the sheet names and instead I want to use the sheet's index. I'm sure there is a blatantly obvious solution but I've tried searching and can't find it.