Difference between revisions of "Creating our first button in VBA"
From Ribbon Commander Documentation
Line 34: | Line 34: | ||
== Code Analysis == | == Code Analysis == | ||
+ | <syntaxhighlight lang="vb"> | ||
+ | ' Add a new group to our tab | ||
+ | With .groups.Add(New rxGroup) | ||
+ | .Label = "My Group" | ||
+ | '... | ||
+ | End With | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | Each [[rxTab]] object has a collection of [[rxGroup]] objects (accessible through its .groups property). Here we add a new group to our tab's groups and label it 'My Group' | ||
+ | |||
+ | |||
+ | <syntaxhighlight lang="vb"> | ||
+ | ' Add a new button to our group | ||
+ | With .Buttons.Add(New rxButton) | ||
+ | .Label = "My Button" | ||
+ | |||
+ | End With | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | Each [[rxGroup]] object has a collection of [[rxButton]] objects (accesible through its .buttons property). Here we add a new button to out group's buttons and label it 'My Button' | ||
+ | |||
== Adding a handler for the button's onAction delegate == | == Adding a handler for the button's onAction delegate == |
Revision as of 18:14, 10 March 2013
Contents
Prerequisites
We recommend you go though A 'hello world' VBA program before going into this example.
Creating a button
Public Sub CreateMyUI()
With rxCustomUI.defaultInstance
' Clear old state
.Clear
' Add a new tab
With .ribbon.tabs.Add(New rxTab)
.Label = "My First Tab"
' Add a new group to our tab
With .groups.Add(New rxGroup)
.Label = "My Group"
' Add a new button to our group
With .Buttons.Add(New rxButton)
.Label = "My Button"
End With
End With
End With
' Render the UI
.Refresh
End With
End Sub
Code Analysis
' Add a new group to our tab With .groups.Add(New rxGroup) .Label = "My Group" '... End With
Each rxTab object has a collection of rxGroup objects (accessible through its .groups property). Here we add a new group to our tab's groups and label it 'My Group'
' Add a new button to our group With .Buttons.Add(New rxButton) .Label = "My Button" End With
Each rxGroup object has a collection of rxButton objects (accesible through its .buttons property). Here we add a new button to out group's buttons and label it 'My Button'