首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >激活格式刷,效果等同于双击

激活格式刷,效果等同于双击
EN

Stack Overflow用户
提问于 2015-09-21 03:56:25
回答 1查看 400关注 0票数 0

我知道ALT+H,F,P激活格式刷,但这只激活它为您的下一次选择,而双击格式刷激活工具,直到用户按ESC键。

我希望Excel 2010 VBA代码可以激活Format Painter进行多个选择,直到我按ESC键为止。基本上,我正在请求激活格式刷双击设置的VBA代码。

EN

回答 1

Stack Overflow用户

发布于 2015-09-22 21:22:46

我记得我的代码库里有它。我还上传了示例宏文件,其中有3个按钮切换复制,切换剪切和切换粘贴。当您按下说切换复制按钮时,您将在功能区上看到此功能被启用或禁用。HTH

Ribbon_xml_macro.xlsm https://www.dropbox.com/s/rrg292652ug137g/Ribbon_xml_macro.xlsm?dl=0

使用包含禁用命令的ribbon xml。

代码语言:javascript
复制
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<commands>
        <!-- Disablae right click menu -->
        <command idMso="Cut" enabled="false"/>
        <command idMso="Copy" enabled="false"/>
        <command idMso="Paste" enabled="false"/>
        <command idMso="PasteMenu" enabled="false"/>
        <command idMso="PasteAsPictureMenu" enabled="false"/>
</commands>
</customUI>

使用包含启用命令的ribbon xml。

代码语言:javascript
复制
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="rxIRibbonUI_onLoad">
<commands>
        <!-- Disablae right click menu -->
        <command idMso="Cut" getEnabled="rxshared_getEnabled"/>
        <command idMso="Copy" getEnabled="rxshared_getEnabled"/>
        <command idMso="Paste" getEnabled="rxshared_getEnabled"/>
        <command idMso="PasteMenu" getEnabled="rxshared_getEnabled"/>
        <command idMso="PasteAsPictureMenu" getEnabled="rxshared_getEnabled"/>
</commands>
</customUI>

xlsm标准代码模块中的代码

代码语言:javascript
复制
Private m_blnCutEnabled As Boolean
Private m_blnCopyEnabled As Boolean
Private m_blnPasteEnabled As Boolean
Private m_rbxRibbon As IRibbonUI
Sub ToogleCut()

    m_blnCutEnabled = Not m_blnCutEnabled
    m_rbxRibbon.Invalidate

End Sub
Sub ToogleCopy()

    m_blnCopyEnabled = Not m_blnCopyEnabled
    m_rbxRibbon.Invalidate

End Sub
Sub TooglePaste()

    m_blnPasteEnabled = Not m_blnPasteEnabled
    m_rbxRibbon.Invalidate

End Sub

Sub rxIRibbonUI_onLoad(ribbon As IRibbonUI)
    Set m_rbxRibbon = ribbon
End Sub
Sub rxshared_getEnabled(Control As IRibbonControl, ByRef returnedVal)

    Select Case Control.ID
    Case "Cut"
        returnedVal = m_blnCutEnabled
    Case "Copy"
        returnedVal = m_blnCopyEnabled
    Case "PasteMenu", "Paste", "PasteAsPicture"
        returnedVal = m_blnPasteEnabled
    End Select

End Sub
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32683673

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档