Using AddinModule_OnRibbonBeforeLoad to hard-code ribbon.xml

Add-in Express™ Support Service
That's what is more important than anything else

Using AddinModule_OnRibbonBeforeLoad to hard-code ribbon.xml
 
Bernard Vukas




Posts: 7
Joined: 2013-01-03
Hello,

I would like the capability to create the ribbon UI at run-time, by manually supplying ribbon XML. I've searched your forum and you've recommended AddinModule_OnRibbonBeforeLoad as a good place to do that:


Private Sub AddinModule_OnRibbonBeforeLoad(sender As Object, ByVal e As ADXRibbonBeforeLoadEventArgs) Handles Me.OnRibbonBeforeLoad

        e.Xml = <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
                    <ribbon>
                        <tabs>
                            <tab id="tab1" label="My Tab">
                                <group id="grp1" label="My Group">
                                </group>
                            </tab>
                        </tabs>
                    </ribbon>
                </customUI>

    End Sub


But this doesn't produce a tab or any error messages in Excel. What could I be doing wrong?

Ultimately I'd like to use this approach with my own callbacks, instead of the built-in Ribbon designer provided by Add-in Express. I hope this is possible.
Regards,

Bernard Vukas, Microsoft Office Applications (OBA) Developer

http://www.bvukas.com | http://twitter.com/bvukas
Posted 03 Jan, 2013 09:09:04 Top
Andrei Smolin


Add-in Express team


Posts: 17179
Joined: 2006-05-11
Hi Bernard,

Unfortunately, the forum doesn't seem to be able to handle correctly the formatting for your code. I have just modified it as follows:

User added an image

This works fine for me.

To create a correct Ribbon XML, you need to follow these articles:
- http://msdn.microsoft.com/en-us/library/aa338202(office.12).aspx
- http://msdn.microsoft.com/en-us/library/aa338199(office.12).aspx
- http://msdn.microsoft.com/en-us/library/aa722523(office.12).aspx

Also, you can use Add-in Express components to create a correct Ribbon XML and then substitute the Ribbon XML in the OnRibbonBeforeLoad event. Say, to study the Ribbon XML, I usually call System.Windows.Forms.Clipboard.SetText(e.Xml) in OnRibbonBeforeLoad and then paste the Ribbon XML to a Word document.

May I know why you need to avoid using Add-in Express components?

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 03 Jan, 2013 09:35:29 Top
Bernard Vukas




Posts: 7
Joined: 2013-01-03
Hi Andrei,

I still haven't been able to display the above mentioned tab.

As much as I would love to use the built-in ribbon designer, I can't, because the UI is created at runtime by loading a custom .xml file. This file defines how many button groups, buttons, menus, etc. we will have, and how they are positioned. This file will change from time to time, hence we need the ribbon to support that.

I've been working with RibbonX for many years, without Add-in Express, and have no issue with creating Ribbon XML by hand. However, this first step isn't working for me as of the moment. Any other ideas?
Regards,

Bernard Vukas, Microsoft Office Applications (OBA) Developer

http://www.bvukas.com | http://twitter.com/bvukas
Posted 03 Jan, 2013 09:49:34 Top
Andrei Smolin


Add-in Express team


Posts: 17179
Joined: 2006-05-11
Is your code called? Have you registered the add-in?

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 03 Jan, 2013 09:55:16 Top
Bernard Vukas




Posts: 7
Joined: 2013-01-03
My apologies. It's working great now. I was using XML literals but forgot to use .ToString. Thank you for your prompt response!
Regards,

Bernard Vukas, Microsoft Office Applications (OBA) Developer

http://www.bvukas.com | http://twitter.com/bvukas
Posted 03 Jan, 2013 10:16:38 Top
Andrei Smolin


Add-in Express team


Posts: 17179
Joined: 2006-05-11
No apologies, please. It's just great to have simple problems only. )))

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 03 Jan, 2013 10:24:45 Top