Home » excel » vba – Excel's Print-To-PDF displays OfficeJS Content at incorrect zoom

vba – Excel's Print-To-PDF displays OfficeJS Content at incorrect zoom

Posted by: admin May 14, 2020 Leave a comment

Questions:

If I zoom in really far in Excel, and then goto File>Export>PDF, the content add-in zooms out really far. Alternatively, If I zoom out really far in Excel, and then use File>Export>PDF, the content add-in zooms in really far.

The same thing occurs when using the VBA code:

MySheet.Range("PDF_RANGE").ExportAsFixedFormat xlTypePDF, path, OpenAfterPublish:=True

This is clearly a Microsoft Office bug, but is there anything I can do to alleviate it?


Note: I am unable to test this in Excel2016, this may be an Excel2013 only issue.

How to&Answers:

Here’s a simple solution to alleviate some of the issues:

Dim scu As Boolean: scu = Application.ScreenUpdating
Application.ScreenUpdating = False
    Dim zoom As Integer: zoom = ActiveWindow.zoom
    ActiveWindow.zoom = 100
        Master.Range("PDF_RANGE").ExportAsFixedFormat xlTypePDF, path, OpenAfterPublish:=True
    ActiveWindow.zoom = zoom
Application.ScreenUpdating = scu

Unfortunately the IE control still re-renders even when Application.ScreenUpdating is set to False, but hopefully these issues are fixed in later versions of Office.