Private Sub IDTExtensibility2_OnConnection(ByVal Application As Object, ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As Object, custom() As Variant)
Set xlApp = Application
CreateMenus '创建2003菜单 <---你这里是呼叫 CreateMenus
End Sub
但你创建菜单函数名称是写 创建自定义工具栏()
Private Sub 创建自定义工具栏() <--应该改成 CreateMenus
....
...
假如你有宣告严格定义变数 Option Explicit ,
那麽 Form 可能找不到 xlApp这变数
Public xlApp As Excel.Application, 可能必须放在一个新的 Module 里面
When the new project opens you will have a Form called frmAddin and
a Designer object called Connect. Remove the form from the project as it is a sample form and we don’t need it.
To do this goto Project/References, uncheck the VB Extensibility Library
and then find the reference to the Microsoft Excel Object Model. Check the box next to it and click OK.
不需要参考 VB Extensibility Library , 但需要参考 Microsoft Excel Object Library
还有
Installing the Addin in Excel
As we set the initial load behaviour to 'Startup' in the designer the Addin should load automatically on reloading Excel. If startup isn’t selected then you may need to load it manually. To do this you need to select the 'Com Addins' menu option in Excel.