nava1000
asked on
Adding attribute to xml custompart in docx Word document at run time using VBA
I am saving data included in Word document in XML format in the ActiveDocument.CustomXmlPa rts.
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:
How to add a node at runtime with an attribute: <City id='3'>LA</City>
Thank you
Nava
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>
Thank you
Nava
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER