0

Using the Custom UI Editor for Microsoft Office, using Excel 365, I added a custom group to a ribbon using this code:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
  <ribbon>
    <tabs>

      <tab idMso="TabHome" >
        <group id="customGroup1" label="My Group" insertAfterMso="GroupEditingExcel">

          <button id="customButton1" label="Click Me" size="large" 
        onAction="Macro1()" imageMso="HappyFace" />
        </group>
      </tab>

    </tabs>
  </ribbon>
</customUI>

When I run the macros from this button, I get several error messages. (But not when I run it from the Macros windows or any other way.) I'd like to step through the code, but it ignores breakpoints and Stop commands.

Is there a way to step through the code when launched this way?

EDIT: A possible clue: this fellow was having one of the same errors I am: Calling an excel macro from the ribbon. To apply the same remedy I'd have to add control As IRibbonControl to my Sub custombutton1(). But if I have a Sub custombutton1(), I don't know where it is.

EDIT: Never mind; I learned that this is a "Callback" that I have to add to a module. Now the macro runs fine. However, I'd still like an answer to my original question: How can I step through the code to debug it?

Community
  • 1
  • 1
Shawn V. Wilson
  • 1,002
  • 3
  • 17
  • 42

1 Answers1

0

You need to ensure "Macro1()" is on module level, should solve your issues.

EarlyBird2
  • 296
  • 2
  • 14