Search code examples
excelvbams-officeribbonx

Excel Custom UI Editor For Microsoft Office Resizable buttons


I am trying to create custom ribbon tab in Excel with resizable buttons, based on the size of the window. I am using Custom UI Editor For Microsoft Office. I would like that the buttons will change to small when I shrink Excel, like they do in other tabs. The code that I wrote in Custom UI Editor For Microsoft Office is below. Here size is defined as large. Is it possible to set it as auto so it will change automatically based on the size of the window?

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
    <ribbon>
        <tabs>
            <tab id="CustomTab" label="Custom Tab" insertAfterMso="TabView">
                <group id="ImportRequestGroup" label="Import Requests" imageMso="Refresh">
                    <button id="RefreshButton" label="Refresh" size="large" onAction="RefreshAction" imageMso="Refresh" />
                    <button id="ImportRequestButton" label="Import Requests" size="large" onAction="ImportRequestAction" imageMso="OutlineDemoteToBodyText" />
                </group>
                <group id="ShowViewsGroup" label="Show views" imageMso="FrameCreateLeft">
                    <button id="ShowCalanderButton" label="Show Calander" size="large" onAction="ShowCalanderAction" imageMso="FrameCreateLeft" />
                    <button id="ViewPlanButton" label="View Plan" size="large" onAction="ViewPlanAction" imageMso="ViewFullScreenView" />
                    <button id="SortPlanButton" label="Sort Plan" size="large" onAction="SortPlanAction" imageMso="Bullets" />
                    <button id="FilterNoneButton" label="Filter none" size="large" onAction="FilterNoneAction" imageMso="FilterToggleFilter" />
                    <button id="HideAbsenceButton" label="Hide Absence" size="large" onAction="HideAbsenceAction" imageMso="CharacterBorder" />
                </group>
                <group id="ManageRowsGroup" label="Manage rows" imageMso="ActionInsertAccess">
                    <button id="InsertRowButton" label="Insert Row" size="large" onAction="InsertRowAction" imageMso="ActionInsertAccess" />
                    <button id="MoveToArchaveButton" label="Move to Archave" size="large" onAction="MoveToArchaveAction" imageMso="SourceControlCheckOut" />
                </group>
                <group id="EmailReportsGroup" label="Email reports" imageMso="ChangesDiscardAndRefresh">
                    <button id="CalculateDifferenceButton" label="Calculate Difference" size="large" onAction="CalculateDifferenceAction" imageMso="ChangesDiscardAndRefresh" />
                    <button id="DaysReminderButton" label="5 days Reminder" size="large" onAction="DaysReminderAction" imageMso="MailMergeStartEmail" />
                </group>
                <group id="ReportsGroup" label="Reports" imageMso="AcceptInvitation">
                    <button id="ApprovePlanButton" label="Approve Plan" size="large" onAction="ApprovePlanAction" imageMso="AcceptInvitation" />
                    <button id="Report14DaysButton" label="Report 14 days" size="large" onAction="Report14DaysAction" imageMso="ChooseForm" />
                    <button id="ReportTechnicianButton" label="Report Technician" size="large" onAction="ReportTechnicianAction" imageMso="CompareAndCombine" />
                    <button id="WeeklyViewButton" label="Weekly View" size="large" onAction="WeeklyViewAction" imageMso="GroupMarginsAndPadding" />
                </group>
                <group id="CheckDuplicatesGroup" label="Check duplicates" imageMso="OutlineUngroupMenu">
                    <button id="CheckEquipmenButton" label="Check Equipmen" size="large" onAction="CheckEquipmenAction" imageMso="OutlineUngroupMenu" />
                    <button id="CheckTechnicianButton" label="Check Technician" size="large" onAction="CheckTechnicianAction" imageMso="SharingOpenWssTaskList" />
                </group>
                <group id="SpotfireFilesGroup" label="Spotfire files" imageMso="Chart3DColumnChart">
                    <button id="SpotfirePlanAndArchiveButton" label="Spotfire Plan and Archive" size="large" onAction="SpotfirePlanAndArchiveAction" imageMso="Chart3DColumnChart" />
                    <button id="SpotfireRealizationReportButton" label="Spotfire Realization Report" size="large" onAction="SpotfireRealizationReportAction" imageMso="SharingOpenWssContactList" />
                </group>
                <group id="FormatingGroup" label="Formating" imageMso="AutoFormat">
                    <button id="ConditionalFormatingButton" label="Conditional Formating" size="large" onAction="ConditionalFormating" imageMso="AutoFormat" />
                </group>
            </tab>
        </tabs>
    </ribbon>
</customUI>

I tried to find the solution online with no luck.


Solution

  • Resizing custom controls is only available for Office 2010 and later. The functionality is somewhat limited for custom controls (as opposed to what Microsoft does with their own controls).

    The capability can only be applied to group controls, not individual controls. The command is an attribute of the <group> tag. Example:

    <group id="ImportRequestGroup" autoScale="true" label="Import Requests" imageMso="Refresh">
    

    Microsoft Documentation reference: https://learn.microsoft.com/en-us/previous-versions/office/developer/office-2010/ee691834(v=office.14)?redirectedfrom=MSDN#auto-scaling-of-custom-controls