XMLNode.Attributes (Word)

Retorna uma coleção XMLNodes que representa os atributos do elemento especificado.

Todos os objetos XMLNode da coleção XMLNodes retornados usando a propriedade Attributes têm um valor de propriedade NodeType de NodeTypewdXMLNodeAttribute.


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