gpt4 book ai didi

VBA 在表格上设置缩放级别

转载 作者:行者123 更新时间:2023-12-04 10:18:36 25 4
gpt4 key购买 nike

我有一个 VBA,它将根据屏幕分辨率设置缩放级别。
但是当您打开工作簿时,它仅适用于 ActiveWindow。
如何在 Excel 中的所有工作表中添加它?

Declare Function GetSystemMetrics32 Lib "user32" _
Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long

Public Sub ScreenRes()
Dim lResWidth As Long
Dim lResHeight As Long
Dim sRes As String

lResWidth = GetSystemMetrics32(0)
lResHeight = GetSystemMetrics32(1)
sRes = lResWidth & "x" & lResHeight
Select Case sRes
Case Is = "800x600"
ActiveWindow.Zoom = 75
Case Is = "1024x768"
ActiveWindow.Zoom = 125
Case Else
ActiveWindow.Zoom = 100
End Select
End Sub

我将在工作簿上调用此模块
Private Sub Workbook_Open()
ScreenRes
End Sub

最佳答案

选择所有Worksheet Objects使用 Worksheets collectionApplication.ActiveWindow property将指向他们所有。

With Worksheets
.Select
ActiveWindow.Zoom = 75
End With

关于VBA 在表格上设置缩放级别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39715728/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com