Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 1369|回复: 1

查看菜单里的命令

[复制链接]
发表于 2013-7-3 11:30 | 显示全部楼层 |阅读模式
在03里,指定一个命令最多只4层。
比如:工作表菜单栏 - 文件(&F) - 打印区域(&T) - 设置打印区域(&S)
  1. Sub test1()
  2.     Dim c, ctl, i
  3.     Cells.Clear
  4.     For Each c In CommandBars       '命令栏
  5.         For Each ctl In c.Controls  '命令栏控件
  6.             i = i + 1
  7.             Cells(i, 1) = c.Index
  8.             Cells(i, 2) = c.NameLocal
  9.             Cells(i, 3) = ctl.Index
  10.             Cells(i, 4) = ctl.Caption
  11.         Next ctl
  12.     Next c
  13. End Sub


  14. Sub test2()
  15.     Dim c1, c2, c3, c4, i
  16.     On Error Resume Next
  17.     Cells.Clear
  18.     For Each c1 In CommandBars    '命令栏
  19.         For Each c2 In c1.Controls    '命令栏控件
  20.             For Each c3 In c2.Controls
  21.                 For Each c4 In c3.Controls
  22.                     i = i + 1
  23.                     Cells(i, 1) = c1.Index
  24.                     Cells(i, 2) = c1.NameLocal
  25.                     Cells(i, 3) = c2.Index
  26.                     Cells(i, 4) = c2.Caption
  27.                     Cells(i, 5) = c3.Index
  28.                     Cells(i, 6) = c3.Caption
  29.                     Cells(i, 7) = c4.Index
  30.                     Cells(i, 8) = c4.Caption
  31.                 Next c4
  32.             Next c3
  33.         Next c2
  34.     Next c1
  35. End Sub
复制代码
问题1:为什么test1显示“工作表菜单栏”下有“操作”;而test2无?






问题2:从test2结果看,有的结果为什么没出现在03里?



发表于 2013-7-3 15:14 | 显示全部楼层
收藏学习了,谢谢

点评

我这也是不懂,想求助学习一下  发表于 2013-7-3 16:33
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-4-28 13:41 , Processed in 0.221596 second(s), 13 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表