VBA Excel – 如何在工作表内的框架内访问控制? 重构/优化
使用Excel 2010
我有一个包含三个ActiveX框架的工作表。 每个框架包含两个或更多的选项button。 工作表上的重置button将选项button的值重置为“False”。
现在,我可以使用每个帧的单独For循环来重置它们:
Private Sub CommandButtonReset_Click() 'This button resets all the OptionButtons to False (unchecked) Dim x As Control For Each x In Frame1.Controls x.Value = False Next For Each x In Frame2.Controls x.Value = False Next For Each x In Frame3.Controls x.Value = False Next End Sub
…但我想重置他们全部使用一个嵌套的For循环,像这样:
Dim xControl as control Dim xFrame as Frame
Dim xControl as control Dim xFrame as Frame
(ActiveSheet.Frames?.Shapes?.OLEObjects?)中的每个xFrame
对于xFrame中的每个xControl
xControl.Value = False
下一个
下一个
在大量的在线search和书籍search之后,我无法find访问活动工作表中每个ActiveX框架的正确方法。
尝试这个:
Sub Tester() Dim o As OLEObject, c For Each o In Sheet1.OLEObjects 'is this a Frame? If TypeName(o.Object) = "Frame" Then For Each c In o.Object.Controls 'is this a checkbox? If TypeName(c) = "CheckBox" Then c.Value = False End If Next End If Next o End Sub
- VBA Windows 7样式button
- 使用Activex控件查看Excel文件
- 在电子表格中使用activexcheckbox控件
- 通过MATLAB ActiveX服务器恢复Excel工作表中的CustomView设置
- 如何使我的C ++ ActiveX控件在Excel中很好地打印?
- Python和Excel:尽pipe有XlSaveConflictResolution值,覆盖现有文件总是会提示
- Excel VBA:closures保存ActiveX大小后提示大小尽pipeThisworkbook.aved = True
- 在Excel中打印并调整MATLABgraphics的大小
- 什么是从Excel ActiveX调用出来的错误代码0x800A01A8?