首页 > 解决方案 > 用于 Microsoft Office 可调整大小按钮的 Excel 自定义 UI 编辑器

问题描述

我正在尝试根据窗口的大小在 Excel 中使用可调整大小的按钮创建自定义功能区选项卡。我正在为 Microsoft Office 使用自定义 UI 编辑器。我希望缩小 Excel 时按钮会变小,就像在其他选项卡中一样。我在 Microsoft Office 的自定义 UI 编辑器中编写的代码如下。这里大小被定义为大。是否可以将其设置为自动,以便它会根据窗口的大小自动更改?

<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>

我试图在网上找到解决方案,但没有运气。

标签: excelvbams-officeribbonx

解决方案


调整自定义控件的大小仅适用于 Office 2010 及更高版本。自定义控件的功能在一定程度上受到限制(与 Microsoft 使用自己的控件所做的相反)。

该功能只能应用于group控件,而不是单个控件。命令是<group>标签的一个属性。例子:

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

微软文档参考: https ://docs.microsoft.com/en-us/previous-versions/office/developer/office-2010/ee691834(v=office.14)?redirectedfrom=MSDN#auto-scaling-of-custom -控制


推荐阅读