Jelle van der Heijden
Jelle van der Heijden

Reputation: 47

Excel VBA ribbon add-in as first tab

I made a custom ribbon addin following this article,

https://www.thespreadsheetguru.com/blog/step-by-step-instructions-create-first-excel-ribbon-vba-addin

It works perfectly but can I move the tab which I have made to be the second tab after the Start tab?

Upvotes: 0

Views: 739

Answers (1)

freeflow
freeflow

Reputation: 4355

You can do what you wish to do but to do so will mean that you need to edit the CustomUI.Xml file which is located in the zip file that is an Office document.

If you are working in VBA then you will best be served by the CustomUI editor tool

https://github.com/OfficeDev/office-custom-ui-editor

This tool will extract the xml file from an Office document, allow you to edit and then save it back to the office document.

This is a good link to start reading up on Ribbon Xml.

https://www.rondebruin.nl/win/s2/win001.htm

The Xml below is from one of my CustomUI for Word. I think it does the same as you are asking in that I inserts the new tab to the left of the Past group on the Home Tab of the ribbon. It also replaces the Paragraph tab with a customised version.

    <tab 
            idMso="TabHome">

            <group
                id = "Home.RegulatoryCMC"
                label = "Regulatory CMC"
                insertBeforeMso = "GroupClipboard"
                visible="true">

                <button 
                    id = "Home.RegulatoryCMC.StartHere"
                    label = "Start Here"
                    onAction = "RibbonCallbacksForButtons.OnAction"
                    getSupertip = "RibbonCallbacksForSupertips.getSuperTip"/>

                <button
                    id="Home.RegulatoryCMC.ShowStylePane" 
                    label="Show Style Pane" 
                    onAction="RibbonCallbacksForButtons.onAction"
                    getSupertip = "RibbonCallbacksForSupertips.getSuperTip"/>

                <button
                    id="Home.RegulatoryCMC.ResetXML" 
                    label="Reset XML" 
                    onAction="RibbonCallbacksForButtons.onAction"
                    getSupertip = "RibbonCallbacksForSupertips.getSuperTip"/>

            </group>

            <group 
                idMso="GroupParagraph"  
                getVisible="RibbonCallbacksForVisibility.getVisible"/>

                <box 
                    id="Home.Paragraph.Status"
                    boxStyle="horizontal">
                    <buttonGroup 
                        id="Home.Paragraph.Alignment">
                        <toggleButton idMso="AlignLeft"/>
                        <toggleButton idMso="AlignCenter"/>
                        <toggleButton idMso="AlignRight"/>
                        <toggleButton idMso="AlignJustify"/>    
                    </buttonGroup>

                    <buttonGroup 
                        id="Home.Paragraph.Marks"
                        visible="true">
                        <toggleButton idMso="ParagraphMarks"/>
                    </buttonGroup>

                </box>

                <box 
                    id="ParagraphIndent"
                    boxStyle="horizontal">
                    <button idMso="IndentDecreaseWord"/>
                    <button idMso="IndentIncreaseWord"/>
                </box>

                <box 
                    id = "ParagraphOther"
                    boxStyle="horizontal">
                    <gallery idMso="LineSpacingGallery"/>
                    <button idMso="SortDialogClassic"/>
                </box>

                <dialogBoxLauncher>
                    <button idMso="ParagraphDialog"/>
                </dialogBoxLauncher>

            </group>

        </tab>

Upvotes: 1

Related Questions