2013-04-14 27 views
0

注意下面的問題是通過創建一個新的工作簿複製所有數據,宏和在其他代碼解決。任何關於什麼原因導致工作簿「突破」的見解都將受到歡迎!的Excel/RibbonUI菜單禁用

我有一個Excel與自定義文件ribbonui。我最近添加了一個帶有新菜單的新組,它已從第一組複製,並刪除了某些項目。

第一組「圖書館」和它的所有控件正常工作。然而,「文檔」組中的「文檔菜單」菜單卻顯示爲灰色,我無法弄清楚原因!

我嘗試在菜單中添加getEnabled和純enabled屬性,但它不會觸發,菜單中包含的按鈕的getEnabled事件也不會發生。

當我打開第一次getLabel事件不火,並正確設置標籤色帶。

我試圖重新命名組和所有控件的東西沒有「文件」的情況下它是相沖突的某種方式,但同樣沒有去。

有誰知道什麼可能導致這種情況發生?

下面是整個customui xml文件。

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<customUI 
    onLoad="CustomUI.Ribbon_onLoad" 
    xmlns="http://schemas.microsoft.com/office/2009/07/customui"> 
    <ribbon> 
    <tabs> 
     <tab 
      id="Main" 
      label="Initech"> 
     <group 
      id="Library" 
      label="Library" 
      tag="Library" 
      centerVertically="true"> 
      <menu 
       id="LibraryMenu" 
       tag="Library" 
       image="gear" 
       getLabel="CustomUI.Menu_getLabel"> 
      <button 
       id="LibraryMenu_Open" 
       tag="Library" 
       label="Open Library" 
       imageMso="FileOpen" 
       getEnabled="CustomUI.Button_getEnabled" 
       onAction="CustomUI.Button_onAction" /> 
      <button 
       id="LibraryMenu_New" 
       tag="Library" 
       label="New Library" 
       imageMso="FileNew" 
       getEnabled="CustomUI.Button_getEnabled" 
       onAction="CustomUI.Button_onAction" /> 
      <menuSeparator 
       id="LibraryMenu_Separator0" /> 
      <button 
       id="LibraryMenu_Save" 
       tag="Library" 
       label="Save" 
       imageMso="FileSave" 
       getEnabled="CustomUI.Button_getEnabled" 
       onAction="CustomUI.Button_onAction" /> 
      <button 
       id="LibraryMenu_Close" 
       tag="Library" 
       label="Close" 
       imageMso="FileClose" 
       getEnabled="CustomUI.Button_getEnabled" 
       onAction="CustomUI.Button_onAction" /> 
      <button 
       id="LibraryMenu_Default" 
       tag="Library" 
       label="Set as Default" 
       imageMso="AcceptInvitation" 
       getEnabled="CustomUI.Button_getEnabled" 
       onAction="CustomUI.Button_onAction" /> 
      <menuSeparator 
       id="LibraryMenu_Separator1" /> 
      <button 
       id="LibraryMenu_Add" 
       tag="Library" 
       label="Add Component" 
       getEnabled="CustomUI.Button_getEnabled" 
       onAction="CustomUI.Button_onAction" /> 
      <button 
       id="LibraryMenu_Editor" 
       tag="Library" 
       label="Edit Menu" 
       getEnabled="CustomUI.Button_getEnabled" 
       onAction="CustomUI.Button_onAction" /> 
      </menu> 
      <dynamicMenu 
       id="LibraryComponents" 
       tag="Library" 
       image="book_stack" 
       getLabel="CustomUI.Menu_getLabel" 
       getEnabled="CustomUI.Menu_getEnabled" 
       getContent="CustomUI.Menu_getContent" /> 
     </group> 
     <group 
      id="Document" 
      label="Document" 
      tag="Document" 
      centerVertically="true"> 
      <menu 
       id="DocumentMenu" 
       tag="Document" 
       imageMso="FileOpen" 
       getLabel="CustomUI.Menu_getLabel"> 
      <button 
       id="DocumentMenu_Open" 
       tag="Document" 
       label="Open Document" 
       imageMso="FileOpen" 
       getEnabled="CustomUI.Button_getEnabled" 
       onAction="CustomUI.Button_onAction" /> 
      <button 
       id="DocumentMenu_New" 
       tag="Document" 
       label="New Document" 
       imageMso="FileNew" 
       getEnabled="CustomUI.Button_getEnabled" 
       onAction="CustomUI.Button_onAction" /> 
      <menuSeparator 
       id="DocumentMenu_Separator0" /> 
      <button 
       id="DocumentMenu_Save" 
       tag="Document" 
       label="Save" 
       imageMso="FileSave" 
       getEnabled="CustomUI.Button_getEnabled" 
       onAction="CustomUI.Button_onAction" /> 
      <button 
       id="DocumentMenu_Close" 
       tag="Document" 
       label="Close" 
       imageMso="FileClose" 
       getEnabled="CustomUI.Button_getEnabled" 
       onAction="CustomUI.Button_onAction" /> 
      </menu> 
     </group> 
     </tab> 
    </tabs> 
    </ribbon> 
</customUI> 

播放約試圖找出怎麼回事小時後更新,原來我的工作簿損壞一些如何。如果我將它放入新的工作簿,代碼工作正常。

回答

0
  1. centerVertically不是一個有效的屬性。 請參閱本link

  2. getEnabled = 「CustomUI.Button_getEnabled」 &的OnAction = 「CustomUI.Button_onAction」
    避免週期。以回調函數的名義,因爲我們無法定義像CustomUI.Button_getEnabled這樣的子/函數。

3當爲按鈕使用getEnabled屬性時,當應用程序需要確定按鈕的啓用狀態時調用回調函數。

sample code - getEnabled for ribbion

+0

centreVertically處於customui.14模式有效的組屬性http://msdn.microsoft.com/en-us/library/documentformat.openxml.office2010.customui.group.centervertically.aspx和在我的潛艇期間確實工作,它允許我指定模塊名稱的子駐留。 (這可能是特定於VBA的)。 – NickSlash

+0

@NickSlash感謝您的信息。 – Santosh