Share via


XMLNode.BaseName Property

Word Developer Reference

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

Syntax

expression.BaseName

expression   Required. A variable that represents a XMLNode object.

Example

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

Visual Basic for Applications
  Sub AddIDAttribute()
    Dim objElement As XMLNode
    Dim objAttribute As XMLNode
For Each objElement In ActiveDocument.XMLNodes
    If objElement.NodeType = wdXMLNodeElement Then
        If objElement.<strong class="bterm">BaseName</strong> = "book" Then
            
            Set objAttribute = objElement.Attributes _
                .Add("author", objElement.NamespaceURI)

            objAttribute.NodeValue = "David Barber"
            
            Exit For
        End If
    End If
Next

End Sub

See Also