Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Or
MVP
MVP

Applying FitZoomToWindow on all sheets via macro

Dear all,

I'm trying to adapt existing macros to apply Fit Zoom To Window for all sheets.

I am easily able to apply Fit Zoom to the active sheet:

ActiveDocument.ActiveSheet.FitZoomToWindow

I am also able to then apply this zoom to all sheets. However, my specific need is to apply Fit Zoom To Window to each sheet individually, as the sizing of objects in each sheet is different and a single zoom setting is not appropriate for all sheets.

I was able to come up with a macro that does this, but in order to do so, it physically cycles between all of the sheets (and back to the original):

Sub Zoom

For i = 0 To ActiveDocument.NoOfSheets - 1

      ActiveDocument.ActivateSheet i

      ActiveDocument.GetApplication.WaitForIdle

        ActiveDocument.ActiveSheet.FitZoomToWindow

        Next    

        ActiveDocument.ActivateSheet 0

End Sub

Unfortunately, this cycling is visible to the user and looks unprofessional and "blinky".

If anyone is familiar with syntax for applying Fit Zoom To Window to a sheet without activating it first, I'd be much obliged if you could assist me with adapting this macro.

Thanks in advance,

Or

5 Replies
Clever_Anjos
Employee
Employee

Maybe you can attach a macro to OnActivate trigger of each sheet

Sub ZoomMe

        ActiveDocument.ActiveSheet.FitZoomToWindow

End Sub

Or
MVP
MVP
Author

This was actually my starting point. Unfortunately, this is not a desirable solution - it interferes with the user's ability to set their own zoom, if they so desire (e.g. they would like an easier-to-read view and are willing to scroll) and users have found it confusing. This is why I'm looking for an OnOpen-based, set-it-and-forget-it solution.

Or
MVP
MVP
Author

Bump - hoping someone in the know will catch sight of this.

Anonymous
Not applicable

rremove the line: ActiveDocument.GetApplication.WaitForIdle

marcus_sommer

Maybe this one:

rem ** fit active sheet to window and apply same zoom to all sheets **

ActiveDocument.ActiveSheet.FitZoomToWindow

ActiveDocument.ActiveSheet.ApplyZoomToAllSheets

- Marcus