【发布时间】:2013-12-16 15:00:19
【问题描述】:
我在 Excel 2010 中有一些表单复选框。我需要在单击它们时执行一些通用代码。为此,我想传递对复选框的引用,但到目前为止,我只能将其键入为形状。
要抢占问题,是的,它们需要是表单复选框而不是 ActiveX 复选框。
我是 VBA 的新手,非常感谢任何帮助。
Sub CheckBox1_Click()
'I really want this reference to be a Checkbox, not a Shape
Dim shape As Shape
Set shape = ActiveSheet.Shapes("Check Box 1")
DoSomething(shape)
End Sub
Sub DoSomething(MSForms.CheckBox)
'I need the reference to be a checkbox as I need to check
'whether it's checked or not here
End Sub
【问题讨论】:
-
表单类别中工作表的复选框属于形状类型。你不能将它们cast为 CheckBox 类型
标签: vba excel office-2010