|
本帖最后由 413191246se 于 2015-8-24 12:24 编辑
* 原始默认的 Word2003 通用模板,在使用的时候有时感到很不方便,过去我一直是手工定义之,现在可以在任何某天,在原始默认的通用空白模板 Normal.dot 中用宏来定义添加内置命令按钮相应工具栏上,大大方便工作。仅仅是添加了部分内置命令按钮,就会有很好的效果,大家不妨试试(这还不算宏按钮)。
* 建议:运行本宏一次,然后可以删除之,以节省内存。以后使用新模板时再使用一次即可。
* 更新:添加了工具栏重置语句(可以不必重新生成 Normal.dot 了,直接用本宏),及自定义《F5:保存》/《F6:关闭》/《Alt+F12:录制宏》快捷键/热键。使用本宏后按 F5 就保存文档,F6 关闭文档,按 Alt+F12 录制新宏(最后一个按钮:多页,建议放到工具栏的最右边,靠边,这样好用,用鼠标点击它斜向下拖动即可)。
*Word2003通用模板Normal.dot自定义内置按钮(宏)v2.3 代码:
- Sub 自定义内置按钮()
- '重置工具栏
- CommandBars("Standard").Reset
- CommandBars("Formatting").Reset
- CommandBars("Tables and Borders").Reset
- CommandBars("Full Screen").Reset
- '常用工具栏
- CommandBars("Standard").Controls.Add Type:=msoControlButton, ID:=4 '打印
- CommandBars("Standard").Controls.Add Type:=msoControlButton, ID:=141 '查找
- CommandBars("Standard").Controls.Add Type:=msoControlButton, ID:=7391 '标尺
- CommandBars("Standard").Controls.Add Type:=msoControlButton, ID:=247 '页面设置
- CommandBars("Standard").Controls.Add Type:=msoControlButton, ID:=3462 '分页
- CommandBars("Standard").Controls.Add Type:=msoControlButton, ID:=809 '剪贴板
- CommandBars("Standard").Controls.Add(Type:=msoControlButton, ID:=2823, Parameter:="宋体").Caption = "宋"
- CommandBars("Standard").Controls.Add(Type:=msoControlButton, ID:=2823, Parameter:="仿宋_GB2312").Caption = "仿"
- CommandBars("Standard").Controls.Add(Type:=msoControlButton, ID:=2823, Parameter:="楷体_GB2312").Caption = "楷"
- CommandBars("Standard").Controls.Add(Type:=msoControlButton, ID:=2823, Parameter:="黑体").Caption = "黑"
- CommandBars("Standard").Controls.Add(Type:=msoControlButton, ID:=2823, Parameter:="Times New Roman").Caption = "英"
- '格式工具栏
- CommandBars("Formatting").Controls.Add Type:=msoControlButton, ID:=62 '增大字体
- CommandBars("Formatting").Controls.Add Type:=msoControlButton, ID:=63 '缩小字体
- CommandBars("Formatting").Controls.Add Type:=msoControlButton, ID:=57 '上标
- CommandBars("Formatting").Controls.Add Type:=msoControlButton, ID:=58 '下标
- CommandBars("Formatting").Controls.Add(Type:=msoControlButton, ID:=2226).FaceId = 219 '标准字符间距
- CommandBars("Formatting").Controls.Add Type:=msoControlButton, ID:=699 '减少段落间距
- CommandBars("Formatting").Controls.Add Type:=msoControlButton, ID:=698 '增加段落间距
- CommandBars("Formatting").Controls.Add(Type:=msoControlButton, ID:=756).FaceId = 274 '全选
- CommandBars("Formatting").Controls.Add Type:=msoControlButton, ID:=54 '单倍行距
- CommandBars("Formatting").Controls.Add Type:=msoControlButton, ID:=55 '1.5倍行距
- CommandBars("Formatting").Controls.Add Type:=msoControlButton, ID:=56 '两倍行距
- CommandBars("Formatting").Controls.Add(Type:=msoControlButton, ID:=178).Style = msoButtonIcon '全屏
- CommandBars("Formatting").Controls.Add Type:=msoControlButton, ID:=6 '页宽
- CommandBars("Formatting").Controls.Add Type:=msoControlButton, ID:=5 '单页
- CommandBars("Print Preview").Controls(4).Copy Bar:=CommandBars("Formatting") '多页
- '表格和边框工具栏
- CommandBars("Tables and Borders").Controls.Add Type:=msoControlButton, ID:=3918 '中部居中
- CommandBars("Tables and Borders").Controls.Add Type:=msoControlButton, ID:=3681 '上方插入行
- CommandBars("Tables and Borders").Controls.Add Type:=msoControlButton, ID:=3683 '下方插入行
- CommandBars("Tables and Borders").Controls.Add Type:=msoControlButton, ID:=293 '删除行
- CommandBars("Tables and Borders").Controls.Add Type:=msoControlButton, ID:=3685 '左侧插入列
- CommandBars("Tables and Borders").Controls.Add Type:=msoControlButton, ID:=3687 '右侧插入列
- CommandBars("Tables and Borders").Controls.Add Type:=msoControlButton, ID:=294 '删除列
- CommandBars("Tables and Borders").Controls.Add Type:=msoControlButton, ID:=3908 '根据窗口调整表格
- CommandBars("Tables and Borders").Controls.Add(Type:=msoControlButton, ID:=803).FaceId = 59 '选定表格
- CommandBars("Tables and Borders").Controls.Add(Type:=msoControlButton, ID:=3704).FaceId = 276 '表格属性
- CommandBars("Tables and Borders").Controls.Add(Type:=msoControlButton, ID:=805).FaceId = 502 '标题行重复
- CommandBars("Tables and Borders").Controls.Add(Type:=msoControlButton, ID:=808).FaceId = 531 '拆分表格
- CommandBars("Tables and Borders").Controls.Add(Type:=msoControlButton, ID:=332).FaceId = 1977 '表格转文本
- CommandBars("Tables and Borders").Controls.Add(Type:=msoControlButton, ID:=3679).FaceId = 358 '删除表格
- '全屏显示工具栏
- CommandBars("Full Screen").Controls.Add Type:=msoControlButton, ID:=6 '页宽
- CommandBars("Full Screen").Controls.Add Type:=msoControlButton, ID:=5 '单页
- CommandBars("Print Preview").Controls(4).Copy Bar:=CommandBars("Full Screen") '多页
- '自定义快捷键
- CustomizationContext = NormalTemplate
- KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyF5), KeyCategory:=wdKeyCategoryMacro, Command:="FileSave"
- KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyF6), KeyCategory:=wdKeyCategoryMacro, Command:="FileClose"
- KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyF12, wdKeyAlt), KeyCategory:=wdKeyCategoryMacro, Command:="ToolsRecordMacroToggle"
- End Sub
复制代码 |
|