打造Excel Ribbon 菜单,2007版本适合最新的2021Excel。
本质是XLM文件,注意,写错一个字符,Excel都不会显示您所写的菜单。还是借助工具写比较方便,参见:《RibbonX:自定义Office 2007功能区》学习心得
具体代码如下:
<?xml version="1.0" standalone="yes"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onl oad="RibbonUI_Initialize">
<ribbon startFromScratch="false">
<tabs>
<tab id="MQCAL125" label="MQCal工程算量" insertAfterMso="TabView">
<group id="MQ1" label="Excel常用">
<control idMso="FileOpen" size="normal" label="打开文件"/>
<control idMso="FileSave" size="normal" label="保存文件"/>
<control idMso="FileSaveAsPdfOrXps" size="normal" label="另存PDF"/>
<control idMso="FilePrintPreview" size="normal" label="打印预览"/>
<control idMso="FilePrint" size="normal" label="直接打印"/>
<control idMso="Cut" size="normal" label="剪贴(X)"/>
<control idMso="Copy" size="normal" label="复制(C)"/>
<control idMso="PasteMenu" size="normal" label="粘贴(P)"/>
<control idMso="PasteValues" size="normal" label="粘贴为值"/>
</group>
<group id="MQ2" label="汇总/清单/目录">
<splitButton id="MQSplitData" size="large">
<button id="MQ20" imageMso="FindNext" label="数据反查" supertip="反查汇总表和分表数据来源,可以互相验证准确性" onAction="FindDatamenu"/>
<menu id="MQ20List" itemSize="large">
<button id="MQ201" imageMso="AccountingFormat" label="单价定位" supertip="汇总的单价 定位到计价清单 价格源头位置,方便检查价格的组成和修改源头价格" onAction="FindPricemenu"/>
</menu>
</splitButton>
<button id="MQ21" imageMso="AutoSum" size="large" label="全部汇总" supertip="汇总总表和分表,快捷键Ctrl+F1" onAction="SumAllmenu"/>
<splitButton id="MQSplitPrice" size="large">
<button id="MQ22Face" imageMso="BulletListDefault" label="导入清单" supertip="汇总总表和分表并导入项目清单,价格清单是增量式更新" onAction="SumAllListmenu"/>
<menu id="MQ22" itemSize="large">
<button id="MQ221" imageMso="DeleteSlideContextual" label="清除清单" supertip="为保证价格清单顺序不变化,清单是增量式更新,如果数据变化太大(比如全新计算),可以清除原计价清单" onAction="CleanListmenu"/>
</menu>
</splitButton>
<button id="MQ23" imageMso="StartOfDocument" size="large" label="生成目录" supertip="先执行汇总和清单后再生成目录" onAction="MakeDirmenu"/>
<splitButton id="MQSplitReter" size="large">
<button id="MQSplitFace" imageMso="BackAttach" label="返回目录" supertip="返回目录表" onAction="GoDirmenu"/>
<!--menu id="MQ24" imageMso="BackAttach" itemSize="large" size="large" label="返回" supertip="返回目录汇总清单表"-->
<menu id="MQ24" itemSize="normal">
<!--button id="MQ241" imageMso="Undo" label="返回目录" supertip="返回目录表" onAction="GoDirmenu" /-->
<button id="MQ242" imageMso="Undo" label="返回汇总" supertip="返回汇总表" onAction="GoSummenu"/>
<button id="MQ243" imageMso="Undo" label="返回分表汇总" supertip="返回分表汇总表" onAction="GoSumSheetmenu"/>
<button id="MQ244" imageMso="Undo" label="返回计价清单" supertip="返回计价清单表" onAction="GoQDmenu"/>
</menu>
</splitButton>
</group>
<group id="MQ3" label="计算式">
<button id="MQ31" imageMso="AdpDiagramIndexesKeys" size="large" label="快速计算" supertip="对当前活动表(计算式表)进行快速计算,快捷键Ctrl+Q" onAction="QuikCalmenu"/>
<button id="MQ32" imageMso="FieldCodes" size="large" label="格式计算" supertip="对当前活动表(计算式表)进行格式计算,快捷键Ctrl+E" onAction="FormatCalmenu"/>
<menu id="MQ33" imageMso="ContentControlDate" itemSize="large" size="large" label="全部计算" supertip="计算所有计算式表">
<button id="MQ331" imageMso="AdpDiagramIndexesKeys" label="快速计算全部" supertip="对所有计算式表进行快速计算,快捷键Ctrl+Shift+Q" onAction="QuikCalAmenu"/>
<button id="MQ332" imageMso="FieldCodes" label="格式计算全部" supertip="对所有计算式表进行格式计算,快捷键Ctrl+Shift+E" onAction="FormatCalAmenu"/>
</menu>
<button id="MQ34" imageMso="DropCapInsertGallery" size="large" label="MQCal编辑器" supertip="MQCal编辑器可浮动在CAD上,方便取数,快捷键F8" onAction="ShowEditmenu"/>
<button id="MQ35" imageMso="FileSaveAsExcelXlsx" size="large" label="新建计算式表" supertip="以模板样式导出一个新的计算式表,快捷键Shift+F11" onAction="NewSheetmenu"/>
<control idMso="NamePasteName" imageMso="GroupBlogProofing" size="large" label="插入代号" supertip="快捷键F3"/>
</group>
<group id="MQ4" label="设置">
<button id="MQ41" imageMso="ControlToolboxOutlook" size="normal" label="模板结构" supertip="设置MQCal模板结构,使计算式表符合您的计算习惯" onAction="SetMBmenu"/>
<button id="MQ42" imageMso="ControlSetControlDefaults" size="normal" label="单位关联" supertip="设置单位和项目关键词关联,使计算式表可选择和自动匹配单位" onAction="SetDWmenu"/>
<button id="MQ43" imageMso="AppointmentColorDialog" size="normal" label="显示规则" supertip="设置字体、字号、颜色、自动计算等" onAction="SetViewmenu"/>
<separator id="MQFG1"/>
<box id="Mycheck" boxStyle="vertical">
<!--menuSeparator id="rxmSep17" title="快捷设置"/-->
<checkBox id="Mycheck3" getPressed="Mycheck3_getPressed" onAction="Mycheck3_click" label="MQ右键菜单" supertip="勾选右键菜单只有MQCal算量功能,否则带Excel右键功能"/>
<checkBox id="Mycheck1" getPressed="Mycheck1_getPressed" onAction="Mycheck1_click" label="自动计算" supertip="勾选自动计算,否则手动点击右键或者菜单计算"/>
<checkBox id="Mycheck2" getPressed="Mycheck2_getPressed" onAction="Mycheck2_click" label="MQ编辑器" supertip="勾选光标在计算式列,自动弹出编辑器,否则按F8或者右键弹出"/>
</box>
</group>
<group id="MQ5" label="MQCal打印">
<button id="MQ51" imageMso="HeaderFooterPageNumberInsert" size="large" label="更新页脚" supertip="自动更新MQCal设置统一的页脚、表头、列宽1页,表头在全部表中采用开始行的上一行作为表头" onAction="SetFootermenu"/>
<splitButton id="MQSplitPrint" size="large">
<button id="MQSplitFacePrint" imageMso="PrintListRange" label="打印当前页" supertip="打印当前活动页" onAction="PrintActmenu"/>
<menu id="MQ52">
<!-- imageMso="PrintListRange" itemSize="large" size="large" label="打印计算式" supertip="打印计算式"-->
<button id="MQ521" imageMso="FilePrint" label="打印当前计算式" supertip="打印当前计算式表,需要在计算式表,如需页脚,请先更新页脚" onAction="PrintCalSheetmenu"/>
<button id="MQ522" imageMso="FilePrint" label="打印全部计算式" supertip="打印全部计算式表,如需页脚,请先更新页脚" onAction="PrintCalSheetsmenu"/>
<button id="MQ523" imageMso="FilePrint" label="打印全部表" supertip="打印包括封面、汇总、计价、计算式等为一个PDF文件,如需页脚,请先更新页脚" onAction="PrintAllmenu"/>
<button id="MQ524" imageMso="FileSaveAsPdf" label="打印全部为PDF" supertip="打印包括封面等所有计算书为PDF,如需页脚,请先更新页脚" onAction="SaveToPdfmenu"/>
</menu>
</splitButton>
</group>
<group id="MQ6" label="关于">
<button id="MQ61" imageMso="FunctionsLogicalInsertGallery" size="large" label="about MQCal" supertip="关于MQCal工程计算式算量" onAction="AboutMQCalmenu"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
显示效果:
实列文件参见:https://club.excelhome.net/thread-1644206-1-1.html
标签:菜单,选项卡,Excel,Excel2007,2007,Ribbon From: https://www.cnblogs.com/qiucq/p/16902832.html