Z 顺序问题
我的电子表格中有多个形状和复选框。我想创建一个函数,当单击相应的复选框时,该函数将特定形状置于前面(比同类形状更高的 Z 顺序)。这是我当前拥有的代码:
Sub CheckBox3_Click()
If CheckBox3.Value = True Then
Sheet1.Shapes("blueoval").ZOrder msoBringToFront
End If
End Sub
每当运行此代码时,我都会收到运行时错误“424”。我是 Excel 的 VBA 新手,因此我们将不胜感激。这段代码有什么问题?缺少什么?等等..谢谢!
I have multiple shapes and checkboxes in a spreadsheet. I want to create a function that places a particular shape to front (a higher Z-order than its peers) when its corresponding checkbox is clicked. This is the code that I currently have:
Sub CheckBox3_Click()
If CheckBox3.Value = True Then
Sheet1.Shapes("blueoval").ZOrder msoBringToFront
End If
End Sub
I get Run-time Error '424' whenever I run this code. I am new to VBA for excel, so any help would be greatly appreciated. What's wrong with this code? What's missing? etc.. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的代码对我有用。
检查:
您的复选框是 ActiveX 控件而不是 Form 控件。
复选框名称为 CheckBox3。
Sheet1 上有一个名为 blueoval 的形状。
带有蓝色椭圆形的工作表名称实际上是 Sheet1(在 Visual Basic 编辑器中检查)。
在 Visual Basic 编辑器中,选择“工具”>“工具”。参考文献并确保没有标记为“缺失”的参考文献。
您的代码位于复选框所在的工作表上,而不是位于单独的模块中。
Your code works for me.
Check that:
Your checkbox is an ActiveX control and not a Form control.
The checkbox name is CheckBox3.
You have a shape on Sheet1 called blueoval.
The sheet name with the blue oval is actually Sheet1 (check this in the Visual Basic Editor).
In the Visual Basic Editor, select Tools > References and make sure there are no references marked MISSING.
Your code is on the worksheet where the checkbox is and not in a separate module.