Difference between revisions of "A 'hello world' VBA program"

From Ribbon Commander Documentation
Jump to: navigation, search
(Creating a tab)
Line 1: Line 1:
 
== Creating a tab ==
 
== Creating a tab ==
 
* Enter the code below in a standard VBA module
 
* Enter the code below in a standard VBA module
<syntaxhighlight lang="vb">
+
<syntaxhighlight lang="vb" line>
 
Public Sub CreateMyUI()
 
Public Sub CreateMyUI()
 
      
 
      
Line 23: Line 23:
 
* Run the sub to create an empty tab labeled 'My First Tab'
 
* Run the sub to create an empty tab labeled 'My First Tab'
 
*: [[image: EmptyTab.png]]
 
*: [[image: EmptyTab.png]]
 +
 +
== Code Analysis ==
 +
<syntaxhighlight lang="vb">
 +
    ' Get a reference to the default rxCustomUI instance
 +
    Dim myCustomUI As rxCustomUI
 +
    Set myCustomUI = rxCustomUI.defaultInstance
 +
</syntaxhighlight>

Revision as of 17:09, 10 March 2013

Creating a tab

  • Enter the code below in a standard VBA module
  1. Public Sub CreateMyUI()
  2.  
  3.     ' Get a reference to the default rxCustomUI instance
  4.     Dim myCustomUI As rxCustomUI
  5.     Set myCustomUI = rxCustomUI.defaultInstance
  6.  
  7.     ' Create a new tab
  8.     Dim myTab As rxTab
  9.     Set myTab = myCustomUI.ribbon.tabs.Add(New rxTab)
  10.  
  11.     ' Give the new tab a label
  12.     myTab.Label = "My First Tab"
  13.  
  14.  
  15.     ' Render the UI
  16.     myCustomUI.Refresh
  17.  
  18. End Sub
  • Run the sub to create an empty tab labeled 'My First Tab'
    EmptyTab.png

Code Analysis

    ' Get a reference to the default rxCustomUI instance
    Dim myCustomUI As rxCustomUI
    Set myCustomUI = rxCustomUI.defaultInstance