T.S.
T.S.

Reputation: 11

Rearranging custom buttons

I am new to programming but I tried to experiment with Excel ribbons. I am using the Custom UI Editor. I wanted to use the insertBefore and insertAfter controls to rearrange my custom buttons. If I do not use a unique namespace and insertAfterQ/insertBeforeQ at button level the order of buttons does not change, however, if I use it I cannot see the related macro (probably due to my namespace), therefore onAction will not do anything after clicking the buttons. I tried various combinations of idQ but I cannot make it work. The below example correctly executes just button 2 which is not in the namespace I specified. A simple example:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" xmlns:x="MyNameSpace">
    <ribbon>
        <tabs>
            <tab idQ="x:customTab" label="My Order Form" insertAfterMso="TabHome">
                <group idQ="x:customGroup" label="My Order Form Tools">
                    <button idQ="x:customButton1" label="Clear" size="large" onAction="DeleteOrder" image="deleteorder" />
                    <button id="customButton2" label="Print" size="large" onAction="ResetOrder" image="resetorder" />
                    <button idQ="x:customButton3" label="Home" size="large" onAction="NewOrder" insertBeforeQ="x:customButton1" image="neworder" />
                </group>                
            </tab>
        </tabs>
    </ribbon>
</customUI>

Is there any way to make onAction work within the namespace? Or is there any other way? Many thanks, TS

Upvotes: 1

Views: 599

Answers (1)

Olle Sj&#246;gren
Olle Sj&#246;gren

Reputation: 5385

Do you really need the namespace?

If you want to rearrange your own controls, just switch places in the xml:

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
    <ribbon>
        <tabs>
            <tab id="customTab" label="My Order Form" insertAfterMso="TabHome">
                <group id="customGroup" label="My Order Form Tools">
                    <button id="customButton3" label="Home" size="large" onAction="NewOrder" image="neworder" />
                    <button id="customButton1" label="Clear" size="large" onAction="DeleteOrder" image="deleteorder" />
                    <button id="customButton2" label="Print" size="large" onAction="ResetOrder" image="resetorder" />
                </group>                
            </tab>
        </tabs>
    </ribbon>
</customUI>

If you want to place your controls relative to built-in controls, use insertBeforeMso or insertAfterMso, like in your "customTab". From what I can tell you only need to use the namespace and idQ-ids if you combine controls from customUI-xml in different files.

Upvotes: 1

Related Questions