• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1828
  • Last Modified:

macro runs twice with called from ribbon

Hello,

I've added a custom ribbon to my xlsm file using the custom UI editer app (Custom UI editor app). For some reason when I click the button the ribbon it runs my macro but only the "msgbox" code fires and it fires twice followed by an odd error message that just say "400" no text.  Even if I comment out all my code expect one msgbox line I get the same results.

Has anyone seen this before? Below is the xml code to create the ribbon.

Thanks
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
    <ribbon>
        <tabs>
            <tab id="customTab" label="Monthly" insertAfterMso="Developer">
                <group id="customGroup" label="Montly">
                    <button id="customButton1" label="Create Instructor Summary" size="large" onAction="modUtilities.CreateNewMonthly()"  />
                </group>

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

Open in new window

0
eshurak
Asked:
eshurak
  • 5
  • 2
  • 2
  • +2
1 Solution
 
Chris BottomleySoftware Quality Lead EngineerCommented:
Can you provide a copy of the sub:

modUtilities.CreateNewMonthly

Chris
0
 
eshurakAuthor Commented:
Hi Chris,

Even when I change the code to:

Sub CreateNewMonthly()
Debug.Print "test"
ActiveWorkbook.ActiveSheet.Range("A1") = Now()
End Sub

I get the same results, so I think the problem is in the xml.  I forgot to mentioned that it does not stop at breakpoints when run from the ribbon.  And to reiterate the code runs fine when run from the vb editor.
0
 
rspahitzCommented:
Not really familiar with using XML for Excel, but doesn't error 400 usually mean web page not found?
(Just a shot in the dark...)
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
SiddharthRoutCommented:
eshurak: Seems like Chris requested you for something :)

Could you please show us the code for "modUtilities.CreateNewMonthly()"

XML seems fine to me.

Sid
0
 
eshurakAuthor Commented:
Rspahitz, thanks there's not really any web pages involved, but it is XML so that might have caused that.  I've attached an image of the error as it is unique.

Sid, yes the code was requested but as I stated earlier even when I simplify the code in " modUtilities.CreateNewMonthly()" I get the same results.  Even if I comment out all code I still get the error message.

Sub CreateNewMonthly()
Debug.Print "test"
ActiveWorkbook.ActiveSheet.Range("A1") = Now()
End Sub


error.bmp
0
 
eshurakAuthor Commented:
Hi,

I've attached my workbook in case there's something that I forgot to mention.
Instructor-Summary-Report-Templa.xlsm
0
 
rspahitzCommented:
Can you run it directly in Excel, without the XML interface?
If so, then the problem is in the XML communication somewhere (which is what I suspect.)
I.E. I don't think the problem is VBA but trying to establish a connection to the VBA.

0
 
eshurakAuthor Commented:
Rspahitz - Exactly.  Yes, when I run the code directly from vb editor it runs fine.  The problem only occurs when the code is called from the ribbon.  The problem is definitely in xml/ribbon.
0
 
Rory ArchibaldCommented:
You have two problems:

1. Remove the parentheses from the onAction property:
onAction="modUtilities.CreateNewMonthly"

2. Change the declaration of your sub:


Sub CreateNewMonthly(control As IRibbonControl)

Regards,
Rory
0
 
Rory ArchibaldCommented:
PS Here's the amended file.
Instructor-Summary-Report-Templa.xlsm
0
 
eshurakAuthor Commented:
Roya, you rock.  I tried differenct varations of that but I never got it right.  Thank you!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 5
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now