Category Archives: FileSystemObject

How To Have Excel VBA Write To XML File

This post is called “How To Have Excel VBA Write To XML File”, and is going to be an enhancement to my previous post:

http://www.vbastring.com/blog/how-to-create-an-excel-userform-to-add-edit-and-delete/

In this post we are going to add a button to our form where we can save the current contents of the worksheet to
an XML file.

Here is the code for the new button. We are creating a text file and then writing the contents of each column to each tag:

When we open ContactList.xml in a XML Editor or the Microsoft Edge browser (because it renders XML good, and should show it, if you have done it correctly) we should see the file contents looking like this:

Now if we need to send this to someone to load into their database or otherwise, our data is structured.

Let me know if you have any questions

****************************************************

Facebooktwittergoogle_plusredditpinterestlinkedinmail
READ MORE