リボンに配置したコントロールは、VBAから直接操作できないから
getEnabledとかgetVisibleなどget~のコールバックを指定
object.InvalidateControl ItemID で再キャッシュする
object.Invalidateで全体を再キャッシュ
'---- Module ---- Option Compare Database Option Explicit Private Rbtab02 As IRibbonUI Sub OnLoad_Ribbon02(Ribbon As IRibbonUI) Set Rbtab02 = Ribbon End Sub Sub setLabel(control As IRibbonControl, ByRef label) Select Case control.id Case "dropdown01" label = "プリンタ" End Select End Sub Sub setScreentip(control As IRibbonControl, ByRef screentip) Select Case control.id Case "dropdown01" screentip = "出力先プリンタ選択" End Select End Sub Sub setItemCount(control As IRibbonControl, ByRef count) Select Case control.id Case "dropdown01" count = Application.Printers.count End Select End Sub Sub setItemLabel(control As IRibbonControl, index As Integer, ByRef label) Select Case control.id Case "dropdown01" label = Application.Printers(index).DeviceName End Select End Sub Sub setItemId(control As IRibbonControl, index As Integer, ByRef id) Select Case control.id Case "dropdown01" id = Application.Printers(index).DeviceName End Select End Sub Sub setItemImage(control As IRibbonControl, index As Integer, ByRef image) Select Case control.id Case "dropdown01" image = "FilePrint" End Select End Sub Sub setItemDefault(control As IRibbonControl, ByRef index) Select Case control.id Case "dropdown01" index = Application.Printer.DeviceName End Select End Sub Sub selectPrinter(control As IRibbonControl, selectedId As String, selectedIndex As Integer) MsgBox control.id & vbTab & selectedId & vbTab & selectedIndex End Sub Sub RibbonUpdate() Rbtab02.Invalidate End Sub Sub ElementUpdate(elementId as String) Rbtab02.InvalidateControl elementId End Sub
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="OnLoad_Ribbon02"> <ribbon startFromScratch="true"> <tabs> <tab id="tab01" label="Tab01"> <group id="g0102" label="g0102"> <dropDown id="dropdown01" getLabel="setLabel" getItemCount="setItemCount" getItemID="setItemId" getItemLabel="setItemLabel" getSelectedItemID="setItemDefault" getScreentip="setScreentip" onAction="selectPrinter" sizeString="wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww" getItemImage="setItemImage" imageMso="FilePrint" /> </group> </tab> </tabs> </ribbon> </customUI>
0 件のコメント:
コメントを投稿