Read/Write variables to XML file using VBA

B

bntringa

Hey all,

I'm looking for documentation to implement the ability to read and
write data to an XML file using VBA.

Basically, I'm looking to store user-defined variables in the XML file
that is then referenced by my VBA code. Default settings for my app
for example would be stored in the XML file, but could be changed by
the end-user with changes being written back to the XML doc.

Can anyone point me in the right direction on this?

I tried searching for XML in the forums but apparently the 3-letter
acronym is too short to use as search criteria.

Thanks!

- Brian
 
G

gimme_this_gimme_that

You can save your workbook in XML format but you don't get much control
of how the XML looks.

This will get you started, it writes :
<xml>
<data>somedata</data>
</xml>

to a file named my.xml


Open "C:\my.xml" For Output As #1
Print #1, "<xml>"+ Chr(10)
Print #1, "<data>somedata</data>+ Chr(10)
Print #1, "</xml>" + Chr(10)
Close #1

I haven't done reading in a while, but last I checked you had to add
MSXML 4.0 and that added an XML library to your references that
provides all the normal DOM subs and functions.

Excel will read XML natively, you can access the worksheet and cells it
creates. Try that first.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top