注次の問題は、すべてのデータ、マクロ、およびその他のコードをコピーする新しいワークブックを作成することで解決されました。ワークブックが「壊れる」原因についての洞察は大歓迎です!
カスタム リボン 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>
何が起こっているのかを把握しようと何時間も遊んだ後、更新すると、ワークブックが何らかの形で破損していることがわかりました。新しいワークブックに配置すると、コードは正常に機能します。