The problem with the code I have is that either it saves all the pages in all the worksheets in the workbook or it saves only the pages in the range specified by the “from” and “to” arguments.
The excel files I am working with have 7 worksheets, and each worksheet can have any amount of pages. If I specify that I want to export “from 1 to 4”, for example, then only the first 4 pages of the first worksheet would be exported as a PDF document, not all the pages of the first 4 worksheets.
Can someone tell me how to achieve what I’m trying to do? The code below is not what I want:
application.ActiveWorkbook.ExportAsFixedFormat(
Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF,
path,
Excel.XlFixedFormatQuality.xlQualityStandard,
true,
true,
1,
4,
false,
Missing.Value);
Here’s the answer: ActiveSheet.PageSetup.Pages.Count