How can reading XMl file in vba

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

Hello guys..

I’m a newbie when it comes to XML, am using Micros VBA,

How do I do this?
1-Reading XML file in a dynamic table
2-what is the best code to insert VBA to a word as dynamic a table

I mean reading from xml to vba and inserted data as table please help me ..


Hi Monaster,

sorry for late reply. I think you would need to share more details on your problem with some code examples.

I would anyway start with reading to read/write to XML files as a start.

If table being dynamic you have in mind that the contents of nodes change – that is not a problem. If the entire structure of the table changes, then that can be a bigger challenge to overcome.

Usually XML tables have a strict schema with node names adhering to the schema so just use XPath to move around the XML as needed.

Changed status to publish

Many thanks For this replay.. Here is a problem I have XML file ,Name URL2 I would like to write a Macro program to read values from XML file and insert them into Word file as a dynamic table What is a recommended solution? These are my code in Micro program its working fine and retrieve data from file URL2.xml Sub TestXML() Dim xmlDoc As Object Dim elements As Object Dim el As Variant Set xmlDoc = CreateObject(“MSXML2.DOMDocument”) xmlDoc.LoadXML XML If xmlDoc.Load(“C:UsersDELLDesktopUrgentxmlURL2.xml”) Then Debug.Print xmlDoc.Text Debug.Print xmlDoc.nodeTypedValue End If End Sub Result : 100 FirstUser MySystem –Value from xml file Null

Simply the best place to learn Excel VBA