Search code examples
excelexcel-2013vba

add-in not working from custom UI


I'm trying to create my first add-in with Custom UI based on this guidance. (As I don't have Visual Studio I'm working with VBA; Excel 2013 in Windows 7)

For testing I've just created one sub in a module:

Sub test()
    MsgBox "test"
End Sub

As described in the guidance, I've created CustomUI folder with CustomUI.xml in it. CustomUI.xml's content:

<?xml version="1.0" encoding="utf-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
  <ribbon>
    <tabs>
      <tab id="TestTab" label="Test tab" >
        <group id="TestGroup" label="Test group" >
          <button id="test" visible="true" size="large" 
                  label="Test Sub" 
                  onAction="test" />
        </group>
      </tab>
    </tabs>
  </ribbon>
</customUI>

Also added
https://msdn.microsoft.com/en-us/library/office/gg597509(v=office.14).aspx
to .rels as described.

Now I've the add-in loading correctly, the only issue that clicking on the newly created ribbon item I'm keep getting below error message (of course the macro works correctly when I start it from VBA editor):
enter image description here

What I'm doing wrong?


Solution

  • Once you have incorporated Public Sub test(control As IRibbonControl) as suggetsed Here and if you are still getting the error then I believe that there is some other code in one of the open Workbooks/Add-In which is interfering with this code.

    1. Close all other open workbooks
    2. Check for any other installed Add-Ins.