Microsoft Excel - Ribbon UI Onaction causes Macro to run twice

Asked By Bichinride on 11-Apr-11 12:44 PM
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"> 
  <ribbon startFromScratch="false"> 
    <tabs> 
      <tab id="CustomTab" label="Test Label">  
        <group id="SimpleControls" label="Test">
          <button id="Button1" image="RibbonUImage" size="large" 
            label="Current Value" 
            onAction="=test()"/>
        </group> 
      </tab> 
    </tabs> 
  </ribbon> 
</customUI>


The ribbon comes up fine but when user clicks the button the macro runs twice. The macro is just a Form.Show.
The form pops and then you hit ok/cancel then it pops again and you hit ok/cancel then Error 400 shows.
Matthew Johnson replied to Bichinride on 11-Apr-11 02:08 PM
I have only played with customizing the ribbon in Access, but what I have for my onAction does not include the equals sign or the parentheses.
Bichinride replied to Matthew Johnson on 11-Apr-11 02:12 PM
Without the Equal sign within the quotes doesnt make a difference but without the parenthesis it comes back with a invalid argument error when the button is clicked.
Matthew Johnson replied to Bichinride on 11-Apr-11 02:13 PM
Are there required arguments for the function you are calling?
Bichinride replied to Matthew Johnson on 11-Apr-11 02:16 PM
Honestly I have no idea.

The form is in a XLA addin. The macro just calls 

Application.Run "TestAddin.xla!TestForm"


wally eye replied to Bichinride on 11-Apr-11 02:44 PM
I had the same thing last week, trying to run a function with a parameter from the OnAction.  I tried using a boolean to toggle the second iteration, and that seemed to prevent the action from occurring, but even then the procedure didn't work right.  I ended up having to take the parameter off of the OnAction command and change my function to get the information directly. 
Bichinride replied to wally eye on 11-Apr-11 02:49 PM
I dont understand what you mean by getting it directly. 
wally eye replied to Bichinride on 11-Apr-11 03:00 PM
Instead of passing a reference to the affected range to the function, have the function reference ActiveCell.Range.  It isn't quite a clean as passing a reference, but the parameters just would not work for me.