0

次の問題は、すべてのデータ、マクロ、およびその他のコードをコピーする新しいワークブックを作成することで解決されました。ワークブックが「壊れる」原因についての洞察は大歓迎です!

カスタム リボン UI を含む Excel ファイルがあります。最近、新しいメニューを含む新しいグループを追加しました。最初のグループからコピーされ、特定のアイテムが削除されました。

最初のグループ「ライブラリ」とそのすべてのコントロールは期待どおりに機能します。ただし、「ドキュメント」グループの「ドキュメントメニュー」メニューはグレー表示されており、その理由がわかりません!

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>

何が起こっているのかを把握しようと何時間も遊んだ後、更新すると、ワークブックが何らかの形で破損していることがわかりました。新しいワークブックに配置すると、コードは正常に機能します。

4

1 に答える 1

0
  1. centerVertically は有効なプロパティではありません。このリンクを参照してください

  2. getEnabled="CustomUI.Button_getEnabled" & onAction="CustomUI.Button_onAction"ピリオドは
    避けてくださいCustomUI.Button_getEnabled のようなサブ/関数を定義できないため、コールバック関数の名前に。

3 ボタンに getEnabled 属性を使用する場合、アプリケーションがボタンの有効状態を判断する必要があるときに、コールバック関数が呼び出されます。

サンプルコード - ribbion の getEnabled

于 2013-04-15T01:35:56.513 に答える