Z 顺序问题

发布于 2024-08-28 13:33:07 字数 310 浏览 4 评论 0原文

我的电子表格中有多个形状和复选框。我想创建一个函数,当单击相应的复选框时,该函数将特定形状置于前面(比同类形状更高的 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 技术交流群。

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

发布评论

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

评论(1

把回忆走一遍 2024-09-04 13:33:07

你的代码对我有用。

检查:

您的复选框是 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文