VBA代码会根据工作表中的文本/对象更改缩放级别?
总而言之,
我一直在寻找实现以下功能的VBA代码:
- 对于包含特定关键字的工作表的缩放为80%
- ,该工作表将包含图片设置的工作
- 表Zoom设置为 60%这里的关键词
是我一直试图操纵以适应这一特殊挑战的代码,我的非代码注释指示我想更改什么:
Sub ZoomSheets()
Dim ws As Worksheet
Application.ScreenUpdating = False
For Each ws *with a picture* In Worksheets
ws.Activate
ActiveWindow.Zoom = 60
Next
For Each ws *that contains X text* In Worksheets
ws.Activate
ActiveWindow.Zoom = 80
Next
For Each ws *that contains Y text* In Worksheets
ws.Activate
ActiveWindow.Zoom = 85
Next
Application.ScreenUpdating = True
End Sub
对于我的工作中的某些可交付方式,经理喜欢在Excel中的某些床单工作簿的不同缩放水平取决于纸张的包含的内容:如果有图片,则为60%,如果在顶部说“ Y”,则为85%,如果顶部为“ X”,则为80%。我已经能够找到在所有表上设置均匀缩放的VBA代码,但是我正在寻找帮助编写更灵活的代码,并可以根据表所包含的内容来更改变焦。
谢谢你!
All,
I've been looking for VBA code that achieves the following:
- Sets zoom to 80% for worksheets that contain a certain key word
- Sets zoom to 60% for worksheets that contain a picture
- Sets zoom to 85% for worksheets that contain a different key word
Here is the code that I have been trying to manipulate to suit this particular challenge, with my non-code comments indicating what I'd like to change:
Sub ZoomSheets()
Dim ws As Worksheet
Application.ScreenUpdating = False
For Each ws *with a picture* In Worksheets
ws.Activate
ActiveWindow.Zoom = 60
Next
For Each ws *that contains X text* In Worksheets
ws.Activate
ActiveWindow.Zoom = 80
Next
For Each ws *that contains Y text* In Worksheets
ws.Activate
ActiveWindow.Zoom = 85
Next
Application.ScreenUpdating = True
End Sub
For a certain deliverable at my job, the manager prefers certain sheets within an excel workbook to be at different zoom levels depending on what the sheet contains: 60% if there is a picture, 85% if it says "Y" at the top and 80% if it says "X" at the top. I've been able to find VBA code that sets a uniform zoom across all sheets, but I am looking for help writing code that is a little more flexible and allows me to vary the zoom depending on what the sheet contains.
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)