|
本帖最后由 yangyangzhifeng 于 2013-7-24 12:30 编辑
运行一下以下代码,自己定位粘贴菜单位置后修改代码- Sub Lqc_List() '分层次显示Excel菜单及工具栏的Index、ID、CaptionSheets.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
复制代码
|
|