I am saving data included in Word document in XML format in the ActiveDocument.CustomXmlPa
I can add node to the XML structure, using VBA code, but I didn't succeed to add new attribute. I've search a lot but didn't find any reference to this.
Here is the code:
Set MyDoc = ActiveDocument
xml = "<Root><Cities><City id='1'>NY</City><City id='2'>Boston</City></Cities></Root>"
Set MyPart = MyDoc.CustomXMLParts.Add(xml)
Set ParentNode = MyPart.SelectSingleNode("//Root/Cities")
MyPart.AddNode ParentNode, "City", , , , "LA"
How to add a node at runtime with an attribute: <City id='3'>LA</City>