XMLNode.Attributes (Word)

Returns an XMLNodes collection that represents the attributes for the specified element.

All XMLNode objects in the XMLNodes collection returned by using the Attributes property have a NodeType property value of wdXMLNodeAttribute.


Sub AddIDAttribute() 
 Dim objElement As XMLNode 
 Dim objAttribute As XMLNode 
 
 For Each objElement In ActiveDocument.XMLNodes 
 If objElement.NodeType = wdXMLNodeElement Then 
 If objElement.BaseName = "book" Then 
 
 Set objAttribute = objElement.Attributes _ 
 .Add("author", objElement.NamespaceURI) 
 
 objAttribute.NodeValue = "David Barber" 
 
 Exit For 
 End If 
 End If 
 Next 
End Sub