ExcelTip.Net留存知识帖 ---【注:附件之前被网盘供应商清空后,现已修复-现已修复-现已修复为本地下载!】
现在位置:首页 > 我的酷贴 > Excel VBA > 分层次显示Excel菜单及工具栏的Index、ID、Caption

分层次显示Excel菜单及工具栏的Index、ID、Caption

作者:绿色风 分类: 时间:2022-08-18 浏览:167
楼主
xyh9999
Sub Lqc_List() '分层次显示Excel菜单及工具栏的Index、ID、Caption
Sheets.Add
i = 0
For Each cmd In CommandBars
i = i + 1
Cells(i, 1) = "Index:" & cmd.Index
Cells(i, 2) = "Name:" & cmd.Name
   For Each ctl In CommandBars(cmd.Name).Controls
      i = i + 1
      Cells(i, 3) = "Index:" & ctl.Index
      Cells(i, 4) = "ID:" & ctl.ID
      Cells(i, 5) = "Caption:" & ctl.Caption
          CtrNum1 = 0
          On Error Resume Next
          CtrNum1 = ctl.Controls.Count
          On Error GoTo 0
          If CtrNum1 >= 1 Then
             For Each ctl1 In ctl.Controls
             i = i + 1
             Cells(i, 6) = "Index:" & ctl1.Index
             Cells(i, 7) = "ID:" & ctl1.ID
             Cells(i, 8) = "Caption:" & ctl1.Caption
                 CtrNum2 = 0
                 On Error Resume Next
                 CtrNum2 = ctl1.Controls.Count
                 On Error GoTo 0
                 If CtrNum2 >= 1 Then
                    For Each ctl2 In ctl1.Controls
                    i = i + 1
                    Cells(i, 9) = "Index:" & ctl2.Index
                    Cells(i, 10) = "ID:" & ctl2.ID
                    Cells(i, 11) = "Caption:" & ctl2.Caption
                        CtrNum3 = 0
                        On Error Resume Next
                        CtrNum3 = ctl2.Controls.Count
                        On Error GoTo 0
                        If CtrNum3 >= 1 Then
                           For Each ctl3 In ctl2.Controls
                           i = i + 1
                           Cells(i, 12) = "Index:" & ctl3.Index
                           Cells(i, 13) = "ID:" & ctl3.ID
                           Cells(i, 14) = "Caption:" & ctl3.Caption
                           Next ctl3
                        End If
                    Next ctl2
                 End If
             Next ctl1
          End If
   Next ctl
Next
End Sub
2楼
wqfzqgk
看了

免责声明

有感于原ExcelTip.Net留存知识的价值及部分知识具有的时间限定性因素, 经与ExcelTip.Net站长Apolloh商议并征得其同意, 现将原属ExcelTip.Net的知识帖采集资料于本站点进行展示, 供有需要的人士查询使用,也慰缅曾经的论坛时代。 所示各个帖子的原作者如对版权有异议, 可与本人沟通提出,或于本站点留言,我们会尽快处理。 在此,感谢ExcelTip.Net站长Apolloh的支持,感谢本站点所有人**绿色风(QQ:79664738)**的支持与奉献,特此鸣谢!
------本人网名**KevinChengCW(QQ:1210618015)**原ExcelTip.Net总版主之一

评论列表
sitemap