Difference between revisions of "Using XML in VBA"
From Ribbon Commander Documentation
(→Serializing to XML) |
|||
Line 25: | Line 25: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | The | + | The VBA code above prints out the following XML code to the debug window: |
<syntaxhighlight lang="xml"> | <syntaxhighlight lang="xml"> | ||
<button supertip="My button supertip" enabled="true" label="My Button"></button> | <button supertip="My button supertip" enabled="true" label="My Button"></button> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
+ | == Instantiating from XML == | ||
+ | <syntaxhighlight lang="vb" line> | ||
+ | Public Sub InstantiateButtonFromXML() | ||
+ | |||
+ | ' Create a new button | ||
+ | Dim myButton As rxButton | ||
+ | Set myButton = New rxButton | ||
+ | |||
+ | myButton.readXml "<button supertip=""My button supertip"" enabled=""true"" label=""My Button""/>" | ||
+ | |||
+ | Debug.Print "supertip=[" & myButton.supertip & "], enabled=[" & myButton.Enabled & "], label=[" & myButton.Label & "]" | ||
+ | |||
+ | End Sub | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | 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> |
Revision as of 23:03, 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
Public Sub InstantiateButtonFromXML()
' Create a new button
Dim myButton As rxButton
Set myButton = New rxButton
myButton.readXml "<button supertip=""My button supertip"" enabled=""true"" label=""My Button""/>"
Debug.Print "supertip=[" & myButton.supertip & "], enabled=[" & myButton.Enabled & "], label=[" & myButton.Label & "]"
End Sub
The VBA code above prints out the following XML code to the debug window:
supertip=[My button supertip], enabled=[-1], label=[My Button]