Using macros stored in .XLAM add-on via custom RibbonUI control

Joined
Mar 18, 2009
Messages
5
Reaction score
0
Being sick and tired of the new 2007 ribbon, and not entirely stupid to pay money for untilities that merely reproduce the standard 2003 toolbar in a non-customizable form, I set off to create a ribbon of my liking for Excel 2007.

This I did, using RibbonCustomizer to rearrange everything the way I liked, then pasted the resulting xml code into MSO2007 Custom UI Editor and saved it into an .XLAM file.

Aside from the ribbon, I have two macros there for invoking functions not readily available in the .XLAM's module:

Option Explicit

Sub FilterByCurrentSelection()
On Error Resume Next
ActiveSheet.Range(ActiveCell.Address).AutoFilter Field:=1, Criteria1:=ActiveCell.Value
End Sub

Sub CenterAcrossSelection()
On Error Resume Next
With Selection
.HorizontalAlignment = xlCenterAcrossSelection
End With
End Sub


They run fine if saved in a workbook. But when I, having loaded the XLAM add-on, click on the corresponding RibbonUI buttons, the macros don't run with the error "Wrong number of arguments or invalid property assignment".
This happens even if I comment out all the code and put something harmless there, like msgbox "test".

The onaction statements in xml look valid to me (though I am, indeed, a layman):

<button id="Custombutton726353990" onAction="CenterAcrossSelection" imageMso="AsianLayoutFitText" showLabel="false" label="Center Across Selection" />

<button id="Custombutton889990873" onAction="FilterByCurrentSelection" imageMso="FilterBySelection" showLabel="false" label="Filter by current selection" />

Now the million-dollar question:
How do I make the macros run via the RibbonUI custom buttons?

PS BTW had no such problems with MS Word 2007 and its .DOTM</FONT>
 
Joined
Mar 18, 2009
Messages
5
Reaction score
0
So as not to make people guess, here's the XLAM file attached in case one has to take a look at it.
The reference screenshot which identifies the buttons used for invoking subs are shown here:
40a3d6e0223a.jpg
 

Attachments

  • Versatile Ribbon 2.zip
    9.3 KB · Views: 151
Last edited:
Joined
Mar 18, 2009
Messages
5
Reaction score
0
Found answer elswhere, just needed to add "(control As IRibbonControl)" to subs' name in the module.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top