VBA word / excel:Class_Initialize(),从Ribbon复选框获取属性

时间:2018-03-02 12:23:12

标签: word-vba

我无法找到如何在初始化用户类期间获取Ribbon Checkbox的属性(启用/禁用)的示例。如何在sub Class_Initialize()中调用Checkbox的OnGetPressed 感谢。

1 个答案:

答案 0 :(得分:0)

VBA的问题。

我有一节课:AlScheme

Option Explicit
Private vClearPrg As Boolean

Public Property Get ClearPrg() As Boolean
  ClearPrg = vClearPrg
End Property

Private Sub Class_Initialize()
  Call SetOptions_OnGetPressed(xxxxxxxxx, vClearPrg)
End Sub

模块:MyRibbon

Option Explicit

Dim MyScheme As AlScheme
Public Rib As IRibbonUI

Public Sub AutoExec()
   Set oAppClass.oApp = Word.Application
End Sub

Sub RibbonOnLoad(ribbon As IRibbonUI)
  Set Rib = ribbon
End Sub

Sub SetOptions_OnGetPressed(ByRef control As IRibbonControl, ByRef pressed As Variant)

Set MyScheme = New AlScheme
pressed = New AlScheme.ClearPrg
End Sub

XML:
checkBox id =" _clearFormat" label =" Clear Prg"的OnAction =" SetOptions" getPressed =" SetOptions_OnGetPressed"

如何在初始化用户类时获取属性ClearPrg? (标记为xxxxxxxxx) 或任何其他解决方案。

谢谢。