Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kinuasa/933704d379de7b2ed24e13fb1ad89c19 to your computer and use it in GitHub Desktop.
Save kinuasa/933704d379de7b2ed24e13fb1ad89c19 to your computer and use it in GitHub Desktop.
[リボン・カスタマイズ]checkBoxのオン・オフを動的に変更する 関連Tweet:https://twitter.com/kinuasa/status/1409399077935058944
'標準モジュール
Option Explicit
Private myRibbon As Office.IRibbonUI
Private flgChkSample As Boolean
Private Sub rbnSample_onLoad(ribbon As IRibbonUI)
Set myRibbon = ribbon
flgChkSample = True
End Sub
Private Sub btnSample_onAction(control As IRibbonControl)
flgChkSample = Not flgChkSample
'myRibbon.Invalidate 'リボン全体再描画
myRibbon.InvalidateControl "chkSample" 'コントロール指定で再描画
MsgBox flgChkSample
End Sub
Private Sub chkSample_getPressed(control As IRibbonControl, ByRef returnedVal)
returnedVal = flgChkSample
End Sub
Private Sub chkSample_onAction(control As IRibbonControl, pressed As Boolean)
flgChkSample = pressed
MsgBox flgChkSample
End Sub
<?xml version="1.0" encoding="utf-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="rbnSample_onLoad">
<ribbon>
<tabs>
<tab id="tabSample" label="Sample Tab">
<group id="grpSample" label="Sample Group">
<button id="btnSample" label="Sample Button" size="large" imageMso="HappyFace" onAction="btnSample_onAction" />
<checkBox id="chkSample" label="Sample CheckBox" getPressed="chkSample_getPressed" onAction="chkSample_onAction" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment