为什么分组ActiveX复选框更改OLEObject可见性 [英] Why does grouping ActiveX checkboxes alter OLEObject visibility

查看:317
本文介绍了为什么分组ActiveX复选框更改OLEObject可见性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些代码循环通过Excel工作表上的ActiveX控件。

I have some code that loops through the ActiveX controls on an Excel worksheet. This logs which checkboxes have been selected.

Dim obj AS OLEObject
For Each obj In ActiveSheet.OLEObjects
    If TypeName(obj.Object) = "CheckBox" Then ' loop through all checkboxes to find selections
        BooCheck = obj.Object
        If BooCheck = True Then
           MyArray(j) = obj.Name 'if checkbox selected then store the associated Name
           j = j + 1
        End If
    End If
Next obj

这一切都很好。但是,由于我有一些复选框,我需要移动,我想我会通过Shift /单击设计模式,他们在一起,右键单击并选择组选项。但是,如果我这样做,分组的复选框从OLEObjects中消失。他们去哪里?有没有办法改变我的代码,以便在分组时找到它们?

This all works fine. However, as I have a number of checkboxes that I need to move around I thought I'd group them together by Shift/click in design mode, right click and select the "Group" option. However, if I do this the grouped checkboxes vanish from OLEObjects. Where do they go? Is there a way of altering my code to find them when they are grouped?

推荐答案

引用OLEObjects的方法是这样的:

The way to reference the OLEObjects is like this:

Public Sub ReferenceTest(oSheet As Worksheet, sGroupName As String)

    Dim i               As Long
    Dim oOle            As OLEObject

    With oSheet.Shapes.Range(sGroupName).GroupItems
        For i = 1 To .Count
            Set oOle = .Item(i).OLEFormat.Object
            Debug.Print oOle.Name, oOle.Object.Value
        Next i
    End With

End Sub

只需指定工作表和组名称,例如

Just specify the sheet and group name, e.g.

ReferenceTest ActiveSheet, "Group 1"

这篇关于为什么分组ActiveX复选框更改OLEObject可见性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆