如何禁用 ActiveX 框架?

How can I disable an ActiveX frame?

在 Excel 我有三个框架,其中一个框架包含复选框。根据用户的选择,我希望能够启用和禁用这些 ActiveX 复选框,假设 enabling/disabling 框架是最有效的方法,我尝试了以下代码:

Dim oOle As OLEObject, ws As Worksheet
For Each ws In Worksheets
   For Each oOle In ws.OLEObjects
       oOle.Enabled = False
   Next oOle
Next ws

但这禁用了所有帧,而我只想禁用 Frame2,有人可以帮忙吗?

这有效:

    Dim Ctrl As Control

    For Each Ctrl In Frame2.Controls
         Ctrl.Enabled = False ' Disable the controls
    Next

    For Each Ctrl In Frame2.Controls
         Ctrl.Enabled = True ' Enable the controls
    Next