Modifying a modified Ribbon

FenceFurniture

New Member
Joined
Apr 24, 2016
Messages
33
Been a very long time since I posted....and since I modified my Ribbon.....:)


In 2016, when I purchased this laptop and the Office suite of the time (is that Office 2016?), I made very many mods to the ribbon. Now I want to add three more buttons to the colour swatch, but I'll be blessed if I can remember the procedure.

Here is the current section for fill colours:
Colours for Ribbon.JPG


I want to add three more in an 8th column on the right. I have the macros written in the VBAProject
0. Ribbon Tabs.xlam
and I have the button pngs created in
C:\1. Excel Buttons\Buttons\New folder

I know there's another step that I have to use a certain editor for in an XML (?) document, but I just can't remember what to do. I seem to recall that it was fiddly to do, but that may have been creating the button pngs.

Any help is much appreciated!
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi. So for one brief second, I thought I was a genius for having come up with the whole 'colour buttons on a ribbon' idea and making my own add-in only to come online and see that you've already got one like it! Oh well. On the plus side, this means I know what you'll need to do in order to modify your XML code!

1609634382536.png


Editing software
You're right - you need to edit the XML file within your XLAM file - you have a few options:

(1) the standard approach would be to edit the XML code direct through software such as the Office RibbonX editor (a newer version of Custom UI Editor, I think). You can find links to both on Ron de Bruin's blog (link);

(2) an alternative would be to use something like the add-in created by Andy Pope that tries to make the whole process far less painful (link) - its a very nice (and pretty) add-in, but I would suggest getting used to it on some practice files before 'operating' on your add-in. Thinking about it now, I don't know how well his add-in plays with existing ribbon code - I've only ever used his add-in when making something from scratch.

(3) Doug Glancy also has an add-in that I quite like - I find it is useful for just quickly jumping into the code and making quick adjustments/corrections (link). That said, it's not helpful at all when it comes to using your own images, so I would suggest maybe going with Option 1 or 2 above.

XML code
Given that your ribbon looks just like mine, I suspect that the approach taken with the code will be the same/similar.

XML:
<group id="grpColors" label="Colors">       
    <box id="boxColours" boxStyle="vertical" visible="true">                           
           <button id="btnColour1" image="Red" onAction="ColourBox" />
        <button id="btnColour2" image="Yellow" onAction="ColourBox" />
        ...
        <!-- Put code for additional column here -->
        ..
    </box>
</group>

I suspect that there will be something in your XML code that looks like the above (ie, buttons in a box), and it would just be a matter of using the button code in your file as a template for three more buttons. Let me know if any of the above was helpful at all, or if you have any other questions.
 
Upvote 0
Solution
Bingo - the missing link is filled. Thank you so much Dan! I only had to open the Custom UI Editor and then open the xlam, and all was revealed:

Rich (BB code):
<button id="XP19" size="normal" onAction="CC_0_255_160" image="XP_0_255_160" showLabel="false" />
        <button id="XP20" size="normal" onAction="CC_0_200_120" image="XP_0_200_120" showLabel="false" />
        <button id="XP21" size="normal" onAction="CC_0_160_120" image="XP_0_160_120" showLabel="false" />

I just have to change that to add another column now.

I'm probably also going to create one for common font colours too.
 
Upvote 0
Ok, one small problem - it can't find the new images to load. This is no surprise to me because looking at the path (which has all the other images):
C:\1. Excel Buttons\Buttons\New folder

the give-away was "New Folder". That looks like I've copied them to there as a backup.

However, I can't find any clues in the XML code as to where the currently used images are kept.
 
Upvote 0
Ok, an internet search has told me that I have to insert the images into the XML file, which I have done., but a new problem has arisen. When I try and click the button it says:
"Cannot run the macro CC_NO_FILL" and that appears to me to be because it doesn't know what button XP24 is.

VBA Code:
XML.
<button id="XP19" size="normal" onAction="CC_0_255_160" image="XP_0_255_160" showLabel="false" />
        <button id="XP20" size="normal" onAction="CC_0_200_120" image="XP_0_200_120" showLabel="false" />
        <button id="XP21" size="normal" onAction="CC_0_160_120" image="XP_0_160_120" showLabel="false" />

        <button id="XP22" size="normal" onAction="CC_255_255_255" image="XP_255_255_255" showLabel="false" />
        <button id="XP23" size="normal" onAction="CC_0_0_0" image="XP_0_0_0" showLabel="false" />
        <button id="XP24" size="normal" onAction="CC_NO_FILL" image="XP_NO_FILL" showLabel="false" />
I'll have a search around to see wht I can learn.
 
Upvote 0
No, I'm afraid that last part has got me stumped. How do I tell it that button XP24 runs the macro CC_NO_FILL in the Project 0. Ribbon Tabs.xlam please?

Tricked myself - the macros didn't get saved in 0. Ribbon Tabs.xlam. The strange thing is that it didn't give me a prompt to save it when I shut down Excel (so I could save the XML file in the Custom UI editor).

All good and done!
 
Last edited:
Upvote 0
Hey - sorry, I did actually write a response to your earlier reply but I didn't send it, apparently. I see you've already worked it out, but for the benefit of anyone else who happens to stumble across this post, one option is to store the picture files within the actual XLAM file. I could see from your code that that is what had happened in your case because it used the 'image' attribute. If you were using the inbuilt icon set, it would've had the 'imageMso attribute'. Which method/software did you end up using in order to get it done?
 
Upvote 0
No, I'm afraid that last part has got me stumped. How do I tell it that button XP24 runs the macro CC_NO_FILL in the Project 0. Ribbon Tabs.xlam please?

Tricked myself - the macros didn't get saved in 0. Ribbon Tabs.xlam. The strange thing is that it didn't give me a prompt to save it when I shut down Excel (so I could save the XML file in the Custom UI editor).

All good and done!
This is the intensely annoying thing about Excel - it won't prompt you to save XLAM files. Glad to see you got it working. I was going to say that the most likely cause of that error message is when you have (inadvertently?) got 2+ callback subroutines with the same the name.

Do you think you might make further changes to the the ribbon?
 
Upvote 0
I used Custom UI Editor (which is pretty agricultural) and inserted the images because they were my own png files that I created. I have downloaded the Office Ribbon Editor and will use that next time.

I'll definitely be making some font colour buttons - perhaps 6 - not quite sure why I didn't think of that back when I did all the other ribbon work. Maybe later today.....
 
Upvote 0

Forum statistics

Threads
1,212,933
Messages
6,110,751
Members
448,295
Latest member
Uzair Tahir Khan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top