Excel 2007 VBA Scaling (without using select?)

Okay, so I never had to do anything in VBA where I NEED to activate a sheet or select a cell. But now I'm trying to figure out how to Zoom up to 100% on a bunch of leaf, and all the code that I see (Google results, including answers from this site) seems to select the sheet first:

ActiveWindow.Zoom = 100 

But I found OzGrid code, which apparently implies that it is possible to do this without first selecting a sheet:

Sht.PageSetup.Zoom = 100

(although we set Sht = ActiveSheet above) I tried to do

Set Sht = ThisWorkbook.Worksheets("Sheet1")
Sht.PageSetup.Zoom = 150

but nothing happens ... literally nothing.

So is this possible? Or should I activate the worksheet before I can do the scaling? I have read so many times that this is bad programming practice if you do not need to.

+2
2

, , - , .

, "", , ,

Application.ScreenUpdating = False

, :

Application.ScreenUpdating = True
+3

Application.Screenupdating = False . Application.screenupdating, true.

-1

Source: https://habr.com/ru/post/1653689/


All Articles