Attaching a xml schema to a excel worksheet

I

Ian Mac

This has to be so simple its untrue, but nowhere can I find how to achieve this
simple task, using VB.
I can do the task manually very easily.
create a new worksheet. - Insert -> worksheet
attach schema - data -> xml -> xml source...
in xml Source frame click on XML Maps....
in XML Maps window click on Add
in Select XML Source window select appropriate .xsd file and click open
back to XML Maps window and ok
structure appears in XML source window.

I can also do all the above with VB thus :-

Dim xmlSheet As Worksheet
Set xmlSheet = Worksheets.Add(After:=Sheets("sheet9"))
xmlSheet.Name = "XmlData"

Set xmlObj =
ActiveWorkbook.XmlMaps.Add("C:\subversion\FM\xml\simulate.xsd",
"data")
xmlObj.Name = "data_Map"

Now the next bit is dead easy manually,
go into the XML Source frame click on the top level object in the maps window
to select it now point at it, click and drag to worksheet cell A1 and drop
and the whole structure list appears with all the correct headings in the
columns and as a list as the xml schema says.

So whats the VB to do this?
I've tried macro record and it shows nothing.
I can get as far as creating the list but then I have to puts the names in as
literals in the code, which is odd as they are already know. but only seem
to appear in the .xml object as a string of the schema source, which I would
have to process. There must be an easier way

Help please.
 

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