Excel 2007 VBA缩放(不使用选择?) [英] Excel 2007 VBA Zooming (without using select?)
问题描述
ActiveWindow.Zoom = 100
但是,我确实在OzGrid上找到了一些代码,这似乎意味着它可以在没有首先选择工作表的情况下进行:
Sht.PageSetup.Zoom = 100
(虽然上面我们有Set Sht = ActiveSheet)尝试做
Set Sht = ThisWorkbook.Worksheets(Sheet1)
Sht.PageSetup.Zoom = 150
但没有发生任何事情...字面上没有。
是的,我相信缩放只是对活动工作表有影响。
但是,如果您不想看到每个工作表被激活并缩放,就会发生可以添加行
Application.ScreenUpdating = False
在您的缩放代码之后,然后完成:
Application.ScreenUpdating = True
Okay, so I've never had to do anything in VBA where I was REQUIRED to activate a sheet or select a cell. But, now, I'm trying to figure out how to do Zoom to 100% on a bunch of worksheets, and all the code I see (google results, including answers from this website) seems to select a sheet first:
ActiveWindow.Zoom = 100
But, I did find some code on OzGrid that seems to imply it's possible to do it without selecting a sheet first:
Sht.PageSetup.Zoom = 100
(although above we have Set Sht = ActiveSheet) I tried doing
Set Sht = ThisWorkbook.Worksheets("Sheet1")
Sht.PageSetup.Zoom = 150
but nothing happens... literally nothing.
So, is this possible? Or must I activate a worksheet before I can do the zooming? I've read so many times that this is bad programming practice, unless you absolutely have to.
Yes, I believe zooming is something that only has an effect on an active sheet.
However, if you didn't want to 'see' each sheet getting activated and zoomed as it happens, you could add the line
Application.ScreenUpdating = False
before your zoom code and then after it is done:
Application.ScreenUpdating = True
这篇关于Excel 2007 VBA缩放(不使用选择?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!