Call excel macro from tape

Introduction: I wrote some short excel macros (checked, they work fine) and I want to link them to a button in the ribbon (Excel 2010). I successfully did this in Excel 2007. I use the Custom UI Editor to create a new feed that also works great. Everything is packaged in an .xlam add-in and added to Excel. The tape displays well, all other buttons work, but ...

Problem: when I click the button associated with the macro, I get the error: "the number of parameters is incorrect or the assignment of properties is invalid" (a message translated from Italian may not coincide with English)

Troubleshooting Information: Macros have no parameters. The same macros can be successfully called and executed manually. I can even add the same macros to the quick access toolbar.

Here is the specific part of the script tape:

<group id="DupNumber" label="Number" insertBeforeMso="GroupNumber" > <comboBox idMso="NumberFormatGallery"/> <box id="HN1" boxStyle="horizontal"> <buttonGroup id="HNButtonGroup1"> <button id="Euro" onAction="Roberto.xlam!EURZ" imageMso="F" supertip="text ..."/> <button id="EuroNZ" onAction="Roberto.xlam!EURNZ" imageMso="E" supertip="text ..."/> <button idMso="PercentStyle"/> <button id="Comma" onAction="Roberto.xlam!NewCommaFormat" imageMso="C" supertip="test ..."/> <button idMso="PercentStyle"/> </buttonGroup> </box> 

and here are the macros:

 Sub EURZ() Application.ActiveCell.NumberFormat = "โ‚ฌ #,##0.00" End Sub Sub EURNZ() Application.ActiveCell.NumberFormat = "โ‚ฌ #,##0" End Sub Sub NewCommaFormat() Application.ActiveCell.NumberFormat = "#,##0" End Sub 

Can you help me? thanks roberto

+2
excel ribbon
Aug 18 '11 at 12:35
source share
1 answer

Roberto

I believe that you need to add this parameter to your macro "Manage as IRibbonControl"

So it should look like this:

 Sub EURZ(control As IRibbonControl) Application.ActiveCell.NumberFormat = "โ‚ฌ #,##0.00" End Sub 

Hope this works for you.

-Justin

+9
Aug 18 2018-11-18T00:
source share



All Articles