Excel 2007插件显示,但不工作

我创build了一个出现在用户界面中的Excel插件,但每当我点击它都不起作用。

Option Explicit Public sheetscol As Collection, depshtnm Public hasdeps As Boolean '*********************************** '*finds the external dependencies of the cell, and places them in the 'sheetscol' collection '*********************************** Sub depfinder_eventhandler(control As IRibbonControl) depfinder End Sub '-------------- Sub depfinder ... End sub 

这是XML CustomUI:

 <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" xmlns:m="MattSinSpace"> <ribbon> <tabs> <tab idQ="m:MattTab" label="Matt Tools" insertAfterMso="TabHome"> <group idQ="m:migration" label="migration tools"> <button idQ="m:DepFinderButton1" label="Highlight Dependencies" size="large" onAction="depfinder_eventhandler" imageMso="HappyFace" /> </group> <group idQ="m:RS1" visible = "false"/> <group idQ="m:RS2" visible = "false"/> </tab> </tabs> </ribbon> </customUI> 

我非常擅长制作插件,我一直在使用这个页面来帮助我:

http://erpcoder.wordpress.com/2012/05/30/how-to-create-a-custom-ribbon-addin-for-excel-2010/

看来,事情没有问题,在我的代码和我的用户界面,唯一的区别是,我已经包含了命名空间。

你的问题在于组和button的XML。 您正在使用idQ,这是在加载项之间共享控件时使用的限定符标识符。 你需要这个选项卡,因为你可以共享加载项之间的选项卡,但不是组或button。 以下XML将起作用:

 <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" xmlns:m="MattSinSpace"> <ribbon> <tabs> <tab idQ="m:MattTab" label="Matt Tools" insertAfterMso="TabHome"> <group id="migration" label="migration tools"> <button id="DepFinderButton1" label="Highlight Dependencies" size="large" onAction="depfinder_eventhandler" imageMso="HappyFace" /> </group> <group id="RS1" visible = "false"/> <group id="RS2" visible = "false"/> </tab> </tabs> </ribbon>