I have written code to allow the user to create a PDF of whichever sheets of the workbook they want included. My code works perfectly. It is:
What I want to do now is remove the "ExportAsFixedFormat" line and replace it with a line to print a hard copy of the selected sheets. I have tried it with this code:
That code will only print the FIRST sheet in the selected sheets, and I can't for a life of me figure out why. Any idea why the PDF creation works fine for multiple sheets but when printing a hard copy it will only print the first one?
Code:
Dim SheetsToPrint As String
... code here determines what 'SheetsToPrint' is equal to ...
Sheets(Split(SheetsToPrint, ",")).Select
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
filename:=PDFName, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
What I want to do now is remove the "ExportAsFixedFormat" line and replace it with a line to print a hard copy of the selected sheets. I have tried it with this code:
Code:
Dim SheetsToPrint As String
... code here determines what 'SheetsToPrint' is equal to ...
Sheets(Split(SheetsToPrint, ",")).Select
ActiveSheet.PrintOut Preview:=False, IgnorePrintAreas:=False
That code will only print the FIRST sheet in the selected sheets, and I can't for a life of me figure out why. Any idea why the PDF creation works fine for multiple sheets but when printing a hard copy it will only print the first one?