Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to parse XML from a VBA macro

436 views
Skip to first unread message

Colin Caughie

unread,
Oct 3, 2001, 8:58:33 AM10/3/01
to
Hello,

I would like to write a Word macro which can read and parse an XML file and
generate Word content from it. The idea is to be able to write documentation
in XML and generate both Word content and HTML from it.

Does anyone know of a way of doing this? Can MSXML be used from VBA for
example? Or has anyone written any VBA subroutines for parsing XML that
they'd be willing to share?

Thanks in advance,

Colin Caughie

tim

unread,
Oct 3, 2001, 10:37:39 AM10/3/01
to
Hi Colin,
If you're doing a one-way transfer into Word it should be
rather easy. If you don't have any Word-specific
formatting needs, you might create an XSLT to transform
the XML into HTML then just pull the HTML into Word. You
could even do that dynamically if you want. I have to
populate CustomDocumentProperties to store the metadata in
Word, if you need that, you'll probably have to use the
DOM to pull the XML info into Word. Just set a reference
inside VBA to the XML parser of choice and open up the
document. Something like this:
Public xmlDoc As New MSXML.DOMDocument
xmlDoc.Load (XMLDOCLOCATION)

Dim paras As MSXML.IXMLDOMNodeList
Set paras = metaHelp.getElementsByTagName("para")

presumably you know how to use the DOM to actually stuff
the info into the WOM?

Hope this helps,
--tim

>.
>

Sean

unread,
Oct 3, 2001, 4:29:40 PM10/3/01
to
Yes, you got it. Use the MSXML parser. It's a COM object and totally
callable from VBA. See the microsoft docs online.

"Colin Caughie" <c.ca...@NOSPAMindigovision.com> wrote in message
news:3bbb0b6b$0$225$ed9e...@reading.news.pipex.net...

Richard

unread,
Oct 3, 2001, 4:52:19 PM10/3/01
to
"Colin Caughie" <c.ca...@NOSPAMindigovision.com> wrote in message news:<3bbb0b6b$0$225$ed9e...@reading.news.pipex.net>...


Take a look at the documentation in the Microsoft XML SDK. It can be
downloaded here: http://msdn.microsoft.com/downloads/default.asp?url=/downloads/sample.asp?url=/msdn-files/027/000/542/msdncompositedoc.xml
It has a very good help file in the doc directory.

Eoin Campbell

unread,
Oct 9, 2001, 9:19:48 AM10/9/01
to
You can use MSXML from VBA very easily.
However, the easiest way to get into Word from XML is to use XSLT to convert the
XML into Word2000 HTML with XML islands, and then open that using MS-Word 2000.


--
Eoin Campbell, Technical Director, XML Workshop Ltd,
10 Greenmount Industrial Estate, Harolds Cross, Dublin 12, IRELAND.
Email: ecam...@xmlw.ie
Phone: +353 1 4547811; Fax: +353 1 4731626
Web: http://www.xmlw.ie/

0 new messages