Difference between revisions of "Using XML in VBA"

From Ribbon Commander Documentation
Jump to: navigation, search
(Instantiating from XML)
Line 40: Line 40:
 
     myButton.readXml "<button supertip=""My button supertip"" enabled=""true"" label=""My Button""/>"
 
     myButton.readXml "<button supertip=""My button supertip"" enabled=""true"" label=""My Button""/>"
 
      
 
      
     Debug.Print "supertip=[" & myButton.supertip & "], enabled=[" & myButton.Enabled & "], label=[" & myButton.Label & "]"
+
     Debug.Print "supertip=[" & myButton.supertip & "], enabled=[" & (myButton.Enabled = rxTrue) & "], label=[" & myButton.Label & "]"
 
+
   
 
End Sub
 
End Sub
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
The VBA code above prints out the following XML code to the debug window:
 
The VBA code above prints out the following XML code to the debug window:
<pre>supertip=[My button supertip], enabled=[-1], label=[My Button]</pre>
+
<pre>supertip=[My button supertip], enabled=[True], label=[My Button]</pre>

Revision as of 23:04, 14 March 2013

Introduction

Dynamic RibbonX controls are both

  • Serializable to XML
  • Instantiatable from XML

Serializing to XML

Public Sub SerializingButton()
 
    ' Create a new button
    Dim myButton As rxButton
    Set myButton = New rxButton
 
    ' Build up state
    With myButton
        .label = "My Button"
        .enabled = rxTrue
        .supertip = "My button supertip"
 
        ' Serialize to XML
        Debug.Print .XML
    End With
 
End Sub

The VBA code above prints out the following XML code to the debug window:

<button supertip="My button supertip" enabled="true" label="My Button"></button>

Instantiating from XML

  1. Public Sub InstantiateButtonFromXML()
  2.  
  3.     ' Create a new button
  4.     Dim myButton As rxButton
  5.     Set myButton = New rxButton
  6.  
  7.     myButton.readXml "<button supertip=""My button supertip"" enabled=""true"" label=""My Button""/>"
  8.  
  9.     Debug.Print "supertip=[" & myButton.supertip & "], enabled=[" & (myButton.Enabled = rxTrue) & "], label=[" & myButton.Label & "]"
  10.  
  11. End Sub

The VBA code above prints out the following XML code to the debug window:

supertip=[My button supertip], enabled=[True], label=[My Button]