Ribbon1: 在Office菜单中添加项目

Office菜单就是应用程序窗口左上角的一个小的应用程序按钮,这个按钮被称作Office按钮,包含一些通用的操作或命令,例如打印、保存和发布。定制Office菜单时,其下的命令将影响整个文档,而不是文档的特定部分,例如段落或字体格式。
Office菜单使用下面的XML标记:
  1. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><officeMenu<span style="color:#000000; font-weight:bold">></span></span></span>
  2. <span style="color:#808080; font-style:italic"><!--</span>
  3. <span style="color:#808080; font-style:italic">                Everything else goes here</span>
  4. <span style="color:#808080; font-style:italic">            --></span>
  5. <span style="color:#009900"><span style="color:#000000; font-weight:bold"></officeMenu<span style="color:#000000; font-weight:bold">></span></span></span>

下表列出了Office菜单的子元素。

对象 用来做什么
control 引用通用控件对象,能够表现其它对象例如按钮、拆分按钮、组,等
button 引用通过正常的单击就能执行某类操作的按钮控件
checkbox 引用复选框控件
gallery 引用库控件
toggleButton 引用切换按钮,在True/False值之间切换
menuSeparator 引用菜单分隔条项
splitButton 引用能够用于容纳其它控件例如按钮控件的拆分按钮
menu 引用能够用于容纳其它控件例如按钮控件的菜单控件
dynamicMenu 引用动态菜单,能够在运行时接受动态的XML内容

下图为定制Excel中Office菜单的一个示例。在Office菜单中添加了一个拆分按钮My Tools,包含两个组My Toolset1和My Toolset2。
Ribbon1: 在Office菜单中添加项目
在这个示例中,我们创建了包含菜单(根据特定任务组织的几个按钮)的拆分按钮,XML代码如下:

  1. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><customUI</span> <span style="color:#000066">xmlns</span>=<span style="color:#ff0000">"http://schemas.microsoft.com/office/2006/01/customui"</span><span style="color:#000000; font-weight:bold">></span></span>
  2. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><ribbon</span> <span style="color:#000066">startFromScratch</span>=<span style="color:#ff0000">"false"</span><span style="color:#000000; font-weight:bold">></span></span>
  3. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><officeMenu<span style="color:#000000; font-weight:bold">></span></span></span>
  4. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><splitButton</span></span>
  5. <span style="color:#009900">     <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxsbtn"</span></span>
  6. <span style="color:#009900">       <span style="color:#000066">insertBeforeMso</span>=<span style="color:#ff0000">"FilePrintMenu"</span><span style="color:#000000; font-weight:bold">></span></span>
  7. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><button</span></span>
  8. <span style="color:#009900">         <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxbtnSplitMain"</span></span>
  9. <span style="color:#009900">         <span style="color:#000066">label</span>=<span style="color:#ff0000">"My Tools"</span></span>
  10. <span style="color:#009900">         <span style="color:#000066">imageMso</span>=<span style="color:#ff0000">"CreateModule"</span><span style="color:#000000; font-weight:bold">/></span></span>
  11. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><menu</span></span>
  12. <span style="color:#009900">          <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxmnu"</span></span>
  13. <span style="color:#009900">          <span style="color:#000066">itemSize</span>=<span style="color:#ff0000">"large"</span><span style="color:#000000; font-weight:bold">></span></span>
  14. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><menuSeparator</span></span>
  15. <span style="color:#009900">           <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxsep1"</span></span>
  16. <span style="color:#009900">           <span style="color:#000066">title</span>=<span style="color:#ff0000">"My Toolset 1"</span><span style="color:#000000; font-weight:bold">/></span></span>
  17. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><button</span></span>
  18. <span style="color:#009900">        <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxbtnEmailSheet"</span></span>
  19. <span style="color:#009900">        <span style="color:#000066">imageMso</span>=<span style="color:#ff0000">"FileSendAsAttachment"</span></span>
  20. <span style="color:#009900">        <span style="color:#000066">label</span>=<span style="color:#ff0000">"E-mail sheet as attachment"</span></span>
  21. <span style="color:#009900">            <span style="color:#000066">description</span>=<span style="color:#ff0000">"E-mail the active sheet as an attachment"</span></span>
  22. <span style="color:#009900">            <span style="color:#000066">onAction</span>=<span style="color:#ff0000">"rxshared_click"</span><span style="color:#000000; font-weight:bold">/></span></span>
  23. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><button</span></span>
  24. <span style="color:#009900">        <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxbtnEmailSupport"</span></span>
  25. <span style="color:#009900">        <span style="color:#000066">imageMso</span>=<span style="color:#ff0000">"MessageToAttendeesMenu"</span></span>
  26. <span style="color:#009900">        <span style="color:#000066">label</span>=<span style="color:#ff0000">"E-mail technical support"</span> </span>
  27. <span style="color:#009900">            <span style="color:#000066">description</span>=<span style="color:#ff0000">"E-mail technical support about issues on this application..."</span></span>
  28. <span style="color:#009900">            <span style="color:#000066">onAction</span>=<span style="color:#ff0000">"rxshared_click"</span><span style="color:#000000; font-weight:bold">/></span></span>
  29. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><button</span></span>
  30. <span style="color:#009900">        <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxbtnEmailBug"</span></span>
  31. <span style="color:#009900">        <span style="color:#000066">imageMso</span>=<span style="color:#ff0000">"ResearchPane"</span></span>
  32. <span style="color:#009900">        <span style="color:#000066">label</span>=<span style="color:#ff0000">"E-mail a bug"</span> </span>
  33. <span style="color:#009900">            <span style="color:#000066">description</span>=<span style="color:#ff0000">"E-mail technical support about bugs found on this application..."</span></span>
  34. <span style="color:#009900">            <span style="color:#000066">onAction</span>=<span style="color:#ff0000">"rxshared_click"</span><span style="color:#000000; font-weight:bold">/></span></span>
  35. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><menuSeparator</span></span>
  36. <span style="color:#009900">           <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxsep2"</span></span>
  37. <span style="color:#009900">           <span style="color:#000066">title</span>=<span style="color:#ff0000">"My Toolset 2"</span><span style="color:#000000; font-weight:bold">/></span></span>
  38. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><button</span></span>
  39. <span style="color:#009900">        <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxbtnPrintPDF"</span></span>
  40. <span style="color:#009900">        <span style="color:#000066">imageMso</span>=<span style="color:#ff0000">"FilePrint"</span></span>
  41. <span style="color:#009900">        <span style="color:#000066">label</span>=<span style="color:#ff0000">"Print to PDF"</span> </span>
  42. <span style="color:#009900">            <span style="color:#000066">description</span>=<span style="color:#ff0000">"Print active sheet to PDF file format"</span></span>
  43. <span style="color:#009900">            <span style="color:#000066">onAction</span>=<span style="color:#ff0000">"rxshared_click"</span><span style="color:#000000; font-weight:bold">/></span></span>
  44. <span style="color:#009900"><span style="color:#000000; font-weight:bold"></menu<span style="color:#000000; font-weight:bold">></span></span></span>
  45. <span style="color:#009900"><span style="color:#000000; font-weight:bold"></splitButton<span style="color:#000000; font-weight:bold">></span></span></span>
  46. <span style="color:#009900"><span style="color:#000000; font-weight:bold"></officeMenu<span style="color:#000000; font-weight:bold">></span></span></span>
  47. <span style="color:#009900"><span style="color:#000000; font-weight:bold"></ribbon<span style="color:#000000; font-weight:bold">></span></span></span>
  48. <span style="color:#009900"><span style="color:#000000; font-weight:bold"></customUI<span style="color:#000000; font-weight:bold">></span></span></span>

实际上,菜单控件也可以提供相同的定制而不须像拆分按钮那样的中间步骤,例如上例可以修改如下:

  1. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><customUI</span> <span style="color:#000066">xmlns</span>=<span style="color:#ff0000">"http://schemas.microsoft.com/office/2006/01/customui"</span><span style="color:#000000; font-weight:bold">></span></span>
  2. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><ribbon</span> <span style="color:#000066">startFromScratch</span>=<span style="color:#ff0000">"false"</span><span style="color:#000000; font-weight:bold">></span></span>
  3. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><officeMenu<span style="color:#000000; font-weight:bold">></span></span></span>
  4. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><menu</span></span>
  5. <span style="color:#009900">          <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxmnu"</span></span>
  6. <span style="color:#009900">          <span style="color:#000066">insertBeforeMso</span>=<span style="color:#ff0000">"FilePrintMenu"</span></span>
  7. <span style="color:#009900">          <span style="color:#000066">label</span>=<span style="color:#ff0000">"My Tools"</span></span>
  8. <span style="color:#009900">          <span style="color:#000066">imageMso</span>=<span style="color:#ff0000">"CreateModule"</span></span>
  9. <span style="color:#009900">          <span style="color:#000066">itemSize</span>=<span style="color:#ff0000">"large"</span><span style="color:#000000; font-weight:bold">></span></span>
  10. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><menuSeparator</span></span>
  11. <span style="color:#009900">           <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxsep1"</span></span>
  12. <span style="color:#009900">           <span style="color:#000066">title</span>=<span style="color:#ff0000">"My Toolset 1"</span><span style="color:#000000; font-weight:bold">/></span></span>
  13. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><button</span></span>
  14. <span style="color:#009900">        <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxbtnEmailSheet"</span></span>
  15. <span style="color:#009900">        <span style="color:#000066">imageMso</span>=<span style="color:#ff0000">"FileSendAsAttachment"</span></span>
  16. <span style="color:#009900">        <span style="color:#000066">label</span>=<span style="color:#ff0000">"E-mail sheet as attachment"</span></span>
  17. <span style="color:#009900">            <span style="color:#000066">description</span>=<span style="color:#ff0000">"E-mail the active sheet as an attachment"</span></span>
  18. <span style="color:#009900">            <span style="color:#000066">onAction</span>=<span style="color:#ff0000">"rxshared_click"</span><span style="color:#000000; font-weight:bold">/></span></span>
  19. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><button</span></span>
  20. <span style="color:#009900">        <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxbtnEmailSupport"</span></span>
  21. <span style="color:#009900">        <span style="color:#000066">imageMso</span>=<span style="color:#ff0000">"MessageToAttendeesMenu"</span></span>
  22. <span style="color:#009900">        <span style="color:#000066">label</span>=<span style="color:#ff0000">"E-mail technical support"</span> </span>
  23. <span style="color:#009900">            <span style="color:#000066">description</span>=<span style="color:#ff0000">"E-mail technical support about issues on this application..."</span></span>
  24. <span style="color:#009900">            <span style="color:#000066">onAction</span>=<span style="color:#ff0000">"rxshared_click"</span><span style="color:#000000; font-weight:bold">/></span></span>
  25. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><button</span></span>
  26. <span style="color:#009900">        <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxbtnEmailBug"</span></span>
  27. <span style="color:#009900">        <span style="color:#000066">imageMso</span>=<span style="color:#ff0000">"ResearchPane"</span></span>
  28. <span style="color:#009900">        <span style="color:#000066">label</span>=<span style="color:#ff0000">"E-mail a bug"</span> </span>
  29. <span style="color:#009900">            <span style="color:#000066">description</span>=<span style="color:#ff0000">"E-mail technical support about bugs found on this application..."</span></span>
  30. <span style="color:#009900">            <span style="color:#000066">onAction</span>=<span style="color:#ff0000">"rxshared_click"</span><span style="color:#000000; font-weight:bold">/></span></span>
  31. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><menuSeparator</span></span>
  32. <span style="color:#009900">           <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxsep2"</span></span>
  33. <span style="color:#009900">           <span style="color:#000066">title</span>=<span style="color:#ff0000">"My Toolset 2"</span><span style="color:#000000; font-weight:bold">/></span></span>
  34. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><button</span></span>
  35. <span style="color:#009900">        <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxbtnPrintPDF"</span></span>
  36. <span style="color:#009900">        <span style="color:#000066">imageMso</span>=<span style="color:#ff0000">"FilePrint"</span></span>
  37. <span style="color:#009900">        <span style="color:#000066">label</span>=<span style="color:#ff0000">"Print to PDF"</span> </span>
  38. <span style="color:#009900">            <span style="color:#000066">description</span>=<span style="color:#ff0000">"Print active sheet to PDF file format"</span></span>
  39. <span style="color:#009900">            <span style="color:#000066">onAction</span>=<span style="color:#ff0000">"rxshared_click"</span><span style="color:#000000; font-weight:bold">/></span></span>
  40. <span style="color:#009900"><span style="color:#000000; font-weight:bold"></menu<span style="color:#000000; font-weight:bold">></span></span></span>
  41. <span style="color:#009900"><span style="color:#000000; font-weight:bold"></officeMenu<span style="color:#000000; font-weight:bold">></span></span></span>
  42. <span style="color:#009900"><span style="color:#000000; font-weight:bold"></ribbon<span style="color:#000000; font-weight:bold">></span></span></span>
  43. <span style="color:#009900"><span style="color:#000000; font-weight:bold"></customUI<span style="color:#000000; font-weight:bold">></span></span></span>

结果如下图所示:
Ribbon1: 在Office菜单中添加项目
可以看出,实现的效果并没有太大的差异。如果认真观察,就会发现拆分按钮在箭头和按扭之间有一条分隔线,而菜单则没有。
上面的示例是在Office菜单中添加自已自定义的项目,当然也可以在Office菜单里的内置元素中添加自定义项目或内置项目,此时您需要知道在什么元素中放置项目,下表列出了Office菜单元素。
表:Office菜单元素

元素 类型 IDMSO 应用于
新建 按钮 FileMenu Excel/Access/Word
打开 按钮 FileOpen Excel/Word
打开 按钮 FileOpenDatabase Access
保存 按钮 FileSave Excel/Word/Access
另存为 拆分按钮 FileSaveAsMenu Excel/Word
另存为 拆分按钮 FileSaveAsMenuAccess Access
打印 拆分按钮 FilePrintMenu Excel/Word/Access
准备 菜单 FilePrepareMenu Excel/Word
管理 菜单 FileManageMenu Access
发送 菜单 FileSendMenu Excel/Word
电子邮件 按钮 FileSendAsAttachment Access
发布 菜单 MenuPublish Excel/Word/Access
关闭 按钮 FileClose Excel/Word
关闭数据库 按钮 FileCloseDatabase Access
Office菜单就是应用程序窗口左上角的一个小的应用程序按钮,这个按钮被称作Office按钮,包含一些通用的操作或命令,例如打印、保存和发布。定制Office菜单时,其下的命令将影响整个文档,而不是文档的特定部分,例如段落或字体格式。
Office菜单使用下面的XML标记:
 
 
 
  1. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><officeMenu<span style="color:#000000; font-weight:bold">></span></span></span>
  2. <span style="color:#808080; font-style:italic"><!--</span>
  3. <span style="color:#808080; font-style:italic">                Everything else goes here</span>
  4. <span style="color:#808080; font-style:italic">            --></span>
  5. <span style="color:#009900"><span style="color:#000000; font-weight:bold"></officeMenu<span style="color:#000000; font-weight:bold">></span></span></span>

下表列出了Office菜单的子元素。

对象 用来做什么
control 引用通用控件对象,能够表现其它对象例如按钮、拆分按钮、组,等
button 引用通过正常的单击就能执行某类操作的按钮控件
checkbox 引用复选框控件
gallery 引用库控件
toggleButton 引用切换按钮,在True/False值之间切换
menuSeparator 引用菜单分隔条项
splitButton 引用能够用于容纳其它控件例如按钮控件的拆分按钮
menu 引用能够用于容纳其它控件例如按钮控件的菜单控件
dynamicMenu 引用动态菜单,能够在运行时接受动态的XML内容

下图为定制Excel中Office菜单的一个示例。在Office菜单中添加了一个拆分按钮My Tools,包含两个组My Toolset1和My Toolset2。
Ribbon1: 在Office菜单中添加项目
在这个示例中,我们创建了包含菜单(根据特定任务组织的几个按钮)的拆分按钮,XML代码如下:

  1. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><customUI</span> <span style="color:#000066">xmlns</span>=<span style="color:#ff0000">"http://schemas.microsoft.com/office/2006/01/customui"</span><span style="color:#000000; font-weight:bold">></span></span>
  2. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><ribbon</span> <span style="color:#000066">startFromScratch</span>=<span style="color:#ff0000">"false"</span><span style="color:#000000; font-weight:bold">></span></span>
  3. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><officeMenu<span style="color:#000000; font-weight:bold">></span></span></span>
  4. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><splitButton</span></span>
  5. <span style="color:#009900">     <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxsbtn"</span></span>
  6. <span style="color:#009900">       <span style="color:#000066">insertBeforeMso</span>=<span style="color:#ff0000">"FilePrintMenu"</span><span style="color:#000000; font-weight:bold">></span></span>
  7. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><button</span></span>
  8. <span style="color:#009900">         <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxbtnSplitMain"</span></span>
  9. <span style="color:#009900">         <span style="color:#000066">label</span>=<span style="color:#ff0000">"My Tools"</span></span>
  10. <span style="color:#009900">         <span style="color:#000066">imageMso</span>=<span style="color:#ff0000">"CreateModule"</span><span style="color:#000000; font-weight:bold">/></span></span>
  11. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><menu</span></span>
  12. <span style="color:#009900">          <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxmnu"</span></span>
  13. <span style="color:#009900">          <span style="color:#000066">itemSize</span>=<span style="color:#ff0000">"large"</span><span style="color:#000000; font-weight:bold">></span></span>
  14. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><menuSeparator</span></span>
  15. <span style="color:#009900">           <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxsep1"</span></span>
  16. <span style="color:#009900">           <span style="color:#000066">title</span>=<span style="color:#ff0000">"My Toolset 1"</span><span style="color:#000000; font-weight:bold">/></span></span>
  17. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><button</span></span>
  18. <span style="color:#009900">        <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxbtnEmailSheet"</span></span>
  19. <span style="color:#009900">        <span style="color:#000066">imageMso</span>=<span style="color:#ff0000">"FileSendAsAttachment"</span></span>
  20. <span style="color:#009900">        <span style="color:#000066">label</span>=<span style="color:#ff0000">"E-mail sheet as attachment"</span></span>
  21. <span style="color:#009900">            <span style="color:#000066">description</span>=<span style="color:#ff0000">"E-mail the active sheet as an attachment"</span></span>
  22. <span style="color:#009900">            <span style="color:#000066">onAction</span>=<span style="color:#ff0000">"rxshared_click"</span><span style="color:#000000; font-weight:bold">/></span></span>
  23. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><button</span></span>
  24. <span style="color:#009900">        <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxbtnEmailSupport"</span></span>
  25. <span style="color:#009900">        <span style="color:#000066">imageMso</span>=<span style="color:#ff0000">"MessageToAttendeesMenu"</span></span>
  26. <span style="color:#009900">        <span style="color:#000066">label</span>=<span style="color:#ff0000">"E-mail technical support"</span> </span>
  27. <span style="color:#009900">            <span style="color:#000066">description</span>=<span style="color:#ff0000">"E-mail technical support about issues on this application..."</span></span>
  28. <span style="color:#009900">            <span style="color:#000066">onAction</span>=<span style="color:#ff0000">"rxshared_click"</span><span style="color:#000000; font-weight:bold">/></span></span>
  29. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><button</span></span>
  30. <span style="color:#009900">        <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxbtnEmailBug"</span></span>
  31. <span style="color:#009900">        <span style="color:#000066">imageMso</span>=<span style="color:#ff0000">"ResearchPane"</span></span>
  32. <span style="color:#009900">        <span style="color:#000066">label</span>=<span style="color:#ff0000">"E-mail a bug"</span> </span>
  33. <span style="color:#009900">            <span style="color:#000066">description</span>=<span style="color:#ff0000">"E-mail technical support about bugs found on this application..."</span></span>
  34. <span style="color:#009900">            <span style="color:#000066">onAction</span>=<span style="color:#ff0000">"rxshared_click"</span><span style="color:#000000; font-weight:bold">/></span></span>
  35. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><menuSeparator</span></span>
  36. <span style="color:#009900">           <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxsep2"</span></span>
  37. <span style="color:#009900">           <span style="color:#000066">title</span>=<span style="color:#ff0000">"My Toolset 2"</span><span style="color:#000000; font-weight:bold">/></span></span>
  38. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><button</span></span>
  39. <span style="color:#009900">        <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxbtnPrintPDF"</span></span>
  40. <span style="color:#009900">        <span style="color:#000066">imageMso</span>=<span style="color:#ff0000">"FilePrint"</span></span>
  41. <span style="color:#009900">        <span style="color:#000066">label</span>=<span style="color:#ff0000">"Print to PDF"</span> </span>
  42. <span style="color:#009900">            <span style="color:#000066">description</span>=<span style="color:#ff0000">"Print active sheet to PDF file format"</span></span>
  43. <span style="color:#009900">            <span style="color:#000066">onAction</span>=<span style="color:#ff0000">"rxshared_click"</span><span style="color:#000000; font-weight:bold">/></span></span>
  44. <span style="color:#009900"><span style="color:#000000; font-weight:bold"></menu<span style="color:#000000; font-weight:bold">></span></span></span>
  45. <span style="color:#009900"><span style="color:#000000; font-weight:bold"></splitButton<span style="color:#000000; font-weight:bold">></span></span></span>
  46. <span style="color:#009900"><span style="color:#000000; font-weight:bold"></officeMenu<span style="color:#000000; font-weight:bold">></span></span></span>
  47. <span style="color:#009900"><span style="color:#000000; font-weight:bold"></ribbon<span style="color:#000000; font-weight:bold">></span></span></span>
  48. <span style="color:#009900"><span style="color:#000000; font-weight:bold"></customUI<span style="color:#000000; font-weight:bold">></span></span></span>

实际上,菜单控件也可以提供相同的定制而不须像拆分按钮那样的中间步骤,例如上例可以修改如下:

  1. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><customUI</span> <span style="color:#000066">xmlns</span>=<span style="color:#ff0000">"http://schemas.microsoft.com/office/2006/01/customui"</span><span style="color:#000000; font-weight:bold">></span></span>
  2. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><ribbon</span> <span style="color:#000066">startFromScratch</span>=<span style="color:#ff0000">"false"</span><span style="color:#000000; font-weight:bold">></span></span>
  3. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><officeMenu<span style="color:#000000; font-weight:bold">></span></span></span>
  4. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><menu</span></span>
  5. <span style="color:#009900">          <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxmnu"</span></span>
  6. <span style="color:#009900">          <span style="color:#000066">insertBeforeMso</span>=<span style="color:#ff0000">"FilePrintMenu"</span></span>
  7. <span style="color:#009900">          <span style="color:#000066">label</span>=<span style="color:#ff0000">"My Tools"</span></span>
  8. <span style="color:#009900">          <span style="color:#000066">imageMso</span>=<span style="color:#ff0000">"CreateModule"</span></span>
  9. <span style="color:#009900">          <span style="color:#000066">itemSize</span>=<span style="color:#ff0000">"large"</span><span style="color:#000000; font-weight:bold">></span></span>
  10. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><menuSeparator</span></span>
  11. <span style="color:#009900">           <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxsep1"</span></span>
  12. <span style="color:#009900">           <span style="color:#000066">title</span>=<span style="color:#ff0000">"My Toolset 1"</span><span style="color:#000000; font-weight:bold">/></span></span>
  13. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><button</span></span>
  14. <span style="color:#009900">        <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxbtnEmailSheet"</span></span>
  15. <span style="color:#009900">        <span style="color:#000066">imageMso</span>=<span style="color:#ff0000">"FileSendAsAttachment"</span></span>
  16. <span style="color:#009900">        <span style="color:#000066">label</span>=<span style="color:#ff0000">"E-mail sheet as attachment"</span></span>
  17. <span style="color:#009900">            <span style="color:#000066">description</span>=<span style="color:#ff0000">"E-mail the active sheet as an attachment"</span></span>
  18. <span style="color:#009900">            <span style="color:#000066">onAction</span>=<span style="color:#ff0000">"rxshared_click"</span><span style="color:#000000; font-weight:bold">/></span></span>
  19. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><button</span></span>
  20. <span style="color:#009900">        <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxbtnEmailSupport"</span></span>
  21. <span style="color:#009900">        <span style="color:#000066">imageMso</span>=<span style="color:#ff0000">"MessageToAttendeesMenu"</span></span>
  22. <span style="color:#009900">        <span style="color:#000066">label</span>=<span style="color:#ff0000">"E-mail technical support"</span> </span>
  23. <span style="color:#009900">            <span style="color:#000066">description</span>=<span style="color:#ff0000">"E-mail technical support about issues on this application..."</span></span>
  24. <span style="color:#009900">            <span style="color:#000066">onAction</span>=<span style="color:#ff0000">"rxshared_click"</span><span style="color:#000000; font-weight:bold">/></span></span>
  25. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><button</span></span>
  26. <span style="color:#009900">        <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxbtnEmailBug"</span></span>
  27. <span style="color:#009900">        <span style="color:#000066">imageMso</span>=<span style="color:#ff0000">"ResearchPane"</span></span>
  28. <span style="color:#009900">        <span style="color:#000066">label</span>=<span style="color:#ff0000">"E-mail a bug"</span> </span>
  29. <span style="color:#009900">            <span style="color:#000066">description</span>=<span style="color:#ff0000">"E-mail technical support about bugs found on this application..."</span></span>
  30. <span style="color:#009900">            <span style="color:#000066">onAction</span>=<span style="color:#ff0000">"rxshared_click"</span><span style="color:#000000; font-weight:bold">/></span></span>
  31. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><menuSeparator</span></span>
  32. <span style="color:#009900">           <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxsep2"</span></span>
  33. <span style="color:#009900">           <span style="color:#000066">title</span>=<span style="color:#ff0000">"My Toolset 2"</span><span style="color:#000000; font-weight:bold">/></span></span>
  34. <span style="color:#009900"><span style="color:#000000; font-weight:bold"><button</span></span>
  35. <span style="color:#009900">        <span style="color:#000066">id</span>=<span style="color:#ff0000">"rxbtnPrintPDF"</span></span>
  36. <span style="color:#009900">        <span style="color:#000066">imageMso</span>=<span style="color:#ff0000">"FilePrint"</span></span>
  37. <span style="color:#009900">        <span style="color:#000066">label</span>=<span style="color:#ff0000">"Print to PDF"</span> </span>
  38. <span style="color:#009900">            <span style="color:#000066">description</span>=<span style="color:#ff0000">"Print active sheet to PDF file format"</span></span>
  39. <span style="color:#009900">            <span style="color:#000066">onAction</span>=<span style="color:#ff0000">"rxshared_click"</span><span style="color:#000000; font-weight:bold">/></span></span>
  40. <span style="color:#009900"><span style="color:#000000; font-weight:bold"></menu<span style="color:#000000; font-weight:bold">></span></span></span>
  41. <span style="color:#009900"><span style="color:#000000; font-weight:bold"></officeMenu<span style="color:#000000; font-weight:bold">></span></span></span>
  42. <span style="color:#009900"><span style="color:#000000; font-weight:bold"></ribbon<span style="color:#000000; font-weight:bold">></span></span></span>
  43. <span style="color:#009900"><span style="color:#000000; font-weight:bold"></customUI<span style="color:#000000; font-weight:bold">></span></span></span>

结果如下图所示:
Ribbon1: 在Office菜单中添加项目
可以看出,实现的效果并没有太大的差异。如果认真观察,就会发现拆分按钮在箭头和按扭之间有一条分隔线,而菜单则没有。
上面的示例是在Office菜单中添加自已自定义的项目,当然也可以在Office菜单里的内置元素中添加自定义项目或内置项目,此时您需要知道在什么元素中放置项目,下表列出了Office菜单元素。
表:Office菜单元素

FileNew 是新建。下面的FileMenu是文件那个按钮

元素 类型 IDMSO 应用于
新建 按钮 FileMenu Excel/Access/Word
打开 按钮 FileOpen Excel/Word
打开 按钮 FileOpenDatabase Access
保存 按钮 FileSave Excel/Word/Access
另存为 拆分按钮 FileSaveAsMenu Excel/Word
另存为 拆分按钮 FileSaveAsMenuAccess Access
打印 拆分按钮 FilePrintMenu Excel/Word/Access
准备 菜单 FilePrepareMenu Excel/Word
管理 菜单 FileManageMenu Access
发送 菜单 FileSendMenu Excel/Word
电子邮件 按钮 FileSendAsAttachment Access
发布 菜单 MenuPublish Excel/Word/Access
关闭 按钮 FileClose Excel/Word
关闭数据库 按钮 FileCloseDatabase Access
上一篇:微信小程序大型系统架构中应用Redis缓存要点


下一篇:hdu 1203