BaseName Property

Returns a String that represents the name of the element without any prefix.


expression Required. An expression that returns one of the objects in the Applies To list.


The following example adds the author attribute to the book element in the active document and then sets the value of the attribute.

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
End Sub

Applies to | XMLChildNodeSuggestion Object | XMLNode Object