0

So I was just looking for basic examples of reading xml structure data with visual basic subs/scripts.

specifically, if possible, how can i take structure data of xml, read the data with some vba, and lay it into excel spreadsheets?

or just a learning resource for this type of thing. thanks very much!

3
  • There are two basic ways you might approach this given what you explained: 1) Use VBA from within Excel to read an XML doc and populate a spreadsheet or 2) Use VB.NET and COM interop from outside Excel to create an Excel document. The latter would probably be easier. Which method do you want to use? Commented Feb 2, 2010 at 15:12
  • @Ben, to be honest which ever makes more sense to use is fine, but I would like to learn both actually... Commented Feb 3, 2010 at 3:13
  • The more overlooked option is to use ADODB to create a spreadsheet (for those situations when you don't have Excel installed). This is a handy secret to know when you are running scripts on PC's that may not have Excel installed. Commented Feb 4, 2010 at 3:06

2 Answers 2

4

These three topics will help you get started.

1) Load the XML using MSXML hint - XMLDOC.Load ("D:\folder\yourXML.xml")

2) Read the data with XPath or XML navigator

3) Build Excel Spreadsheet Using Microsoft Excel Object Model

Sign up to request clarification or add additional context in comments.

Comments

3

http://www.dailydoseofexcel.com/archives/2009/06/16/reading-xml-files-in-vba/

http://www.dailydoseofexcel.com/archives/2010/01/21/culling-you-rss-feeds/

These aren't tutorials, just a couple of examples of XML in Excel that might help you identify the objects properties and methods. The first one from 2009 was my first attempt (read: it's terrible) but the comments were helpful for me so they might be helpful for you too.

1 Comment

@dkus I'm impressed that you even attempted to read XML from within VBA. Very well done and thanks for the link!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.