命令栏对象为CommandBar。
由于excel 2007版本开始,微软用ribbon代替了原来常用的菜单栏。
所以很多命令栏都已经不存在了,但是有一些命令栏还是有使用价值的,比如单元格右键菜单栏。
如果要知道具体的命令栏的名称可以使用以下代码批量获得所有的内置命令栏的名称:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
Sub QQ1722187970() On Error Resume Next Dim obj As CommandBar Dim oWK As Worksheet Set oWK = ActiveSheet oWK.Cells.Clear i = 2 For Each obj In Excel.Application.CommandBars With oWK .Range("a1:b1") = Array("命令栏名称", "命令栏中文名称") .Cells(i, "a") = obj.Name .Cells(i, "b") = obj.NameLocal i = i + 1 '显示可以显示的菜单栏 obj.Visible = True End With Next End Sub |
最终获得的结果如下:
命令栏名称 | 命令栏中文名称 |
Worksheet Menu Bar | 工作表菜单栏 |
Chart Menu Bar | 图表菜单栏 |
Circular Reference | 循环引用 |
WordArt | 艺术字 |
Picture | 图片 |
Drawing Canvas | 绘图画布 |
Organization Chart | 组织结构图 |
Diagram | 图示 |
Ink Drawing and Writing | 墨迹绘图与书写 |
Ink Annotations | 墨迹注释 |
Standard | 常用 |
Formatting | 格式 |
PivotTable | 数据透视表 |
Chart | 图表 |
Reviewing | 审阅 |
Forms | 窗体 |
Stop Recording | 停止录制 |
External Data | 外部数据 |
Formula Auditing | 公式审核 |
Full Screen | 全屏显示 |
PivotChart Menu | 数据透视图菜单 |
Visual Basic | Visual Basic |
Web | Web |
Control Toolbox | 控件工具箱 |
Exit Design Mode | 退出设计模式 |
Refresh | 刷新 |
Watch Window | 监视窗口 |
PivotTable Field List | 数据透视表字段列表 |
Borders | 边框 |
Protection | 保护 |
Text To Speech | 文本到语音 |
List | 列表 |
Compare Side by Side | 并排比较 |
Workbook tabs | 工作簿标签 |
Cell | 单元格 |
Column | 列 |
Row | 行 |
Cell | 单元格 |
Column | 柱形图 |
Row | 行 |
Ply | Ply |
XLM Cell | XLM 单元格 |
Document | 文档 |
Desktop | 桌面 |
Nondefault Drag and Drop | 非默认拖放 |
AutoFill | 自动填充 |
Button | 按钮 |
Dialog | 对话框 |
Series | 序列 |
Plot Area | 绘图区 |
Floor and Walls | 基底和墙纸 |
Trendline | 趋势线 |
Chart | 图表 |
Format Data Series | 设置数据系列格式 |
Format Axis | 设置坐标轴格式 |
Format Legend Entry | 设置图例项格式 |
Formula Bar | 编辑栏 |
PivotTable Context Menu | 数据透视表上下文菜单 |
Query | 查询 |
Query Layout | 查询布局 |
AutoCalculate | 自动计算 |
Object/Plot | 对象/图形区 |
Title Bar (Charting) | 标题栏(图表) |
Layout | 框架 |
Pivot Chart Popup | 数据透视图快捷菜单 |
Phonetic Information | 拼音信息 |
Auto Sum | 自动合计 |
Paste Special Dropdown | 选择性粘贴下拉框 |
Find Format | 查找格式 |
Replace Format | 替换格式 |
List Range Popup | 列表区域快捷菜单 |
List Range Layout Popup | 列表区域布局快捷菜单 |
XML Range Popup | XML 区域快捷菜单 |
List Range Layout Popup | 列表区域布局快捷菜单 |
Nil | Nil |
Filter Names | 筛选器名称 |
Excel Previewer | Excel 预览器 |
&Legacy Keyboard Support | 旧式键盘支持(&L) |
Row | 行 |
Column | 列 |
Drawing | 绘图 |
Shadow Settings | 阴影设置 |
3-D Settings | 三维设置 |
Borders | 边框 |
Borders | 边框 |
Draw Border | 绘图边框 |
Chart Type | 图表类型 |
Pattern | 图案 |
Font Color | 字体颜色 |
Fill Color | 填充颜色 |
Line Color | 线条颜色 |
Drawing and Writing Pens | 绘图与书写笔 |
Annotation Pens | 批注笔 |
Drawing and Writing Pens | 绘图和书写笔 |
Annotation Pens | 注释笔 |
Order | 叠放次序 |
Nudge | 微移 |
Align or Distribute | 对齐或分布 |
Rotate or Flip | 旋转或翻转 |
Lines | 直线 |
Connectors | 连接线 |
AutoShapes | 自选图形 |
Callouts | 标注 |
Flowchart | 流程图 |
Block Arrows | 箭头总汇 |
Stars & Banners | 星与旗帜 |
Basic Shapes | 基本形状 |
Insert Shape | 插入形状 |
Shapes | 形状 |
Inactive Chart | 非活动图表 |
Excel Control | Excel 控件 |
Curve | 曲线 |
Curve Node | 曲线结点 |
Curve Segment | 曲线段 |
Pictures Context Menu | 图片上下文菜单 |
OLE Object | OLE 对象 |
ActiveX Control | ActiveX 控件 |
WordArt Context Menu | 艺术字上下文菜单 |
Rotate Mode | 旋转方式 |
Connector | 连接线 |
Script Anchor Popup | 脚本标记快捷菜单 |
Canvas Popup | Canvas Popup |
Organization Chart Popup | Organization Chart Popup |
Diagram | 图表 |
Layout | 版式 |
Select | 选择 |
Task Pane | 任务窗格 |
Property Editor | 属性编辑器 |
Office Clipboard | Office 剪贴板 |
XML Source | XML 源 |
Research | 信息检索 |
XML Document | XML 文档 |
Signatures | 签名 |
Document Actions | 文档操作 |
Clip Art | 剪贴画 |
Selection | 选择 |
Format Object | 设置对象格式 |
Document Management | 文档管理 |
Document Updates | 文档更新 |
Mail Merge Panes | 邮件合并窗格 |
Fax Service | 传真服务 |
Meeting Workspace | 会议工作区 |
Attachment Options | 附件选项 |
Accessibility Checker | 辅助功能检查器 |
Proofing | 校对 |
Dictionaries | 词典 |
Thesaurus | 同义词库 |
Ribbon Adapter | Ribbon Adapter |
Add Command | 添加命令 |
Built-in Menus | 内置菜单 |
Clipboard | 剪贴板 |
Envelope | 信封 |
Status Bar | 状态栏 |
Ribbon | Ribbon |
比如要使用单元格右键菜单栏,可以用以下代码返回对该菜单栏的引用。
1 2 |
Dim obj As CommandBar Set obj = Excel.Application.CommandBars("Cell") |
发表评论