Using events in VBA
We recommend you go though Creating an rxCustomUI object with local dispatch scope in VBA before going into this example.
All Dynamic RibbonX controls that model UI elements with delegates support VBA events. In order to subscribe to events in VBA we need to write our UI code in a VBA class. Since we are using events instead of delegates, the dispatch scope of our customUI is irrelevant.
Subscribing to control events
- Add a new class to your VBA project and name it clsEventsDemoUI
- Enter the following code to the class module
Private m_customUI As rxCustomUI
Private WithEvents m_button As rxButton
Private Sub Class_Initialize()
' Create a new local context
Set m_customUI = rxCustomUI.Create("my_local_context", "My Local Context", DispatchScope_local)
' Initialize the context's UI
' Initializes the context's UI
Private Sub CreateUI()
' Create a new tab
With .ribbon.tabs.Add(New rxTab)
.label = "Local Ctx Tab"
' Create a new group
With .groups.Add(New rxGroup)
.label = "Local Ctx Group"
' Add a new button to the group and subscribe to its events
' NOTE: By assigning the new rxButton object reference to the member variable
' that has been declared 'WithEvents' we are subscribing to the control's
Set m_button = .Buttons.Add(New rxButton)
' Render the UI