2010/03/24

Fluent UI マークアップから列挙 VBA

Fluent UI マークアップからコントロール毎のidを列挙
たまに使いたい時がある
UsysRibbonsからxmlを取得してcollectionに格納するのもいいかも知れん
object.InvalidateControl メソッドでeditBoxだけ一括処理とか
'参照:Microsoft XML v6.0
Sub listUpIdByControl()
Dim xdoc As New DOMDocument
Dim i As Integer
Dim node As IXMLDOMNode
Dim nodes As IXMLDOMNodeList
Dim xmlattr As IXMLDOMAttribute

xdoc.async = True
xdoc.Load "directory+filename"

Set nodes = xdoc.DocumentElement.SelectNodes("//button") ' "//control_type"
For i = 1 To nodes.Length
    Set node = nodes(i - 1)
    Set xmlattr = node.Attributes.getNamedItem("id")
    Debug.Print node.nodeName, xmlattr.Value
Next
End Sub

Sub listUpId(targetXML As String, targetElement As String)
Dim xdoc As New DOMDocument
Dim i As Integer
Dim node As IXMLDOMNode
Dim nodes As IXMLDOMNodeList
Dim xmlattr As IXMLDOMAttribute

xdoc.LoadXML targetXML

Set nodes = xdoc.DocumentElement.SelectNodes("//" & targetElement)
For i = 1 To nodes.Length
    Set node = nodes(i - 1)
    Set xmlattr = node.Attributes.getNamedItem("id")
    Debug.Print node.nodeName, xmlattr.Value
Next
End Sub

0 件のコメント: