I have a Delphi routine which runs through a list of Excel files, opens them with MS Excel, iterates through the sheets setting the PageSetup for each sheet so all columns will fit on one page and then export all sheets to a single PDF.
MSApp := CreateOLEObject('Excel.Application');
doc := MSApp.WorkBooks.Open(fileOpenDialog1.FileName, False, True, EmptyParam, '', '',
True, EmptyParam, EmptyParam, EmptyParam, False, EmptyParam, False, False, EmptyParam);
MSApp.PrintCommunication := False;
doc.Sheets.Item[1].PageSetup.FitToPagesWide := 1;
if doc.Sheets.Count > 1 then
begin
doc.Sheets.Item[1].Select(True);
for i := 2 to doc.Sheets.Count do
begin
doc.Sheets.Item[i].Select(False);
doc.Sheets.Item[i].PageSetup.FitToPagesWide := 1;
end;
end;
doc.ExportAsFixedFormat(xlTypePDF, outPutFile, EmptyParam, False,
EmptyParam, EmptyParam, EmptyParam, False, EmptyParam);
MSApp.PrintCommunication := True;
If there is only one sheet setting FitToPagesWide to 1 page works as expected. However, if there is more than one page and say the first page is too wide, the changes to the PageSetup for the first page do not stick and are lost by the time the file is exported.
Looking at the various examples online and the MS docs, I have been unable to find anything to suggest that the above should not work as expected or that there is some property that needs to be set in order to make PageSetup changes stick before moving on to the next sheet.
I could save each sheet to PDF individually and then merge the PDFs, but it seems to me that shouldn't be necessary.

PageSetup.Zoom := falsebefore settingFitToPagesWide. - John Easley