I am trying to save multiple selected worksheets into the one single PDF.
relativePath = wb.Path & "\" & sheetName & dateToday
wb.Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select
***This is the code in question***.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=relativePath, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=True
I have tried two methods in modifying "This is the code in question"
- I have used 'Selection'
- Result: A blank document is saved as a PDF with nothing in it
- I have used 'ActveSheet'
- Result: A document is saved as a PDF with only the first sheet
- I have used 'wb' (this is the my current workbook, just to test if it works)
- Result: As expected a document is saved as a PDF with ALL sheets inside, this was mainly to test to see if the PDF functionality was working
To clarify, my desired result is sheet1, sheet2 and sheet3 to be saved into the same PDF (i have a bunch of other sheets in my workbook and I will replace the statically coded sheet names with an array when i get it working)
I have gotten both solution 1 and 2 from stackoverflow answers, but both do not work for me where they work for other people.
Can anyone please shed some light on a solution OR at least identify why these two things are happening?