将所有 Excel 工作表设置为定义的缩放级别

发布于 2024-11-05 22:04:14 字数 77 浏览 0 评论 0原文

我的 Excel 工作簿(文件)中有二十多张工作表。是否有一些代码片段或命令我可以应用/使用,以便所有工作表都可以重置为 85% 缩放级别?

I have more than twenty sheets in an Excel workbook (file). Is there some code snippet or a command I could apply/use so that all sheets could be reset to let's say 85% zoom level?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

缱绻入梦 2024-11-12 22:04:14
Sub SetZoom()
    Dim ws As Worksheet

    For Each ws In Worksheets
        ws.Select
        ActiveWindow.Zoom = 85 ' change as per your requirements
    Next ws
End Sub

顺便说一句,如果您只需使用选项卡选择工作簿中的所有工作表,则可以将缩放设置为 85%,它将应用于所有工作表

Sub SetZoom()
    Dim ws As Worksheet

    For Each ws In Worksheets
        ws.Select
        ActiveWindow.Zoom = 85 ' change as per your requirements
    Next ws
End Sub

BTW, if you simply select all worksheets in your workbook using the tabs you can then set the zoom to 85% and it will apply to all worksheets

找回味觉 2024-11-12 22:04:14
Sub SetZoom()

Dim ws As Worksheet
Application.ScreenUpdating = False    'Optional
For Each ws In ActiveWorkbook.Worksheets
    ws.Activate
    ActiveWindow.Zoom = 85
Next
Application.ScreenUpdating = True

End Sub

此代码与上面的代码类似,但在运行宏之前不必选择工作簿中的所有工作表。不要使用除非选择工作表否则无法正常工作的 ws.SelectNext ws,而是更改为 ws.ActivateNext 设置所有工作表的缩放比例。作为可选操作,可以针对包含大量工作表的工作簿禁用 ScreenUpdating

Sub SetZoom()

Dim ws As Worksheet
Application.ScreenUpdating = False    'Optional
For Each ws In ActiveWorkbook.Worksheets
    ws.Activate
    ActiveWindow.Zoom = 85
Next
Application.ScreenUpdating = True

End Sub

This code is similar from the above, but it is not necessary to select all worksheets in your workbook before running the macro. Instead of using ws.Select and Next ws that not work correctly unless you select the worksheets, change to ws.Activate and Next to set the zoom for all the sheets. As optional, the ScreenUpdating can be disabled for a workbook with a lot of sheets.

一曲爱恨情仇 2024-11-12 22:04:14
Option Explicit

Sub FixSheets()
    Dim ws As Worksheet
    For Each ws In Worksheets
        ws.Activate
        ws.UsedRange.Select
        ActiveWindow.Zoom = True 'Zoom sur la sélection
        ActiveCell.Select
    Next ws
End Sub
Option Explicit

Sub FixSheets()
    Dim ws As Worksheet
    For Each ws In Worksheets
        ws.Activate
        ws.UsedRange.Select
        ActiveWindow.Zoom = True 'Zoom sur la sélection
        ActiveCell.Select
    Next ws
End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文