How Can I Name and XML Tag In MS Word 2003 with VBA

S

Sgraves

I am parsing word documents to xml but when I open them in xml the file
structure is not define. I was thinking that maybe there is a way to give
the tags a name and then export each file.

I am creating text boxes that will be fill in with the information by
diffirent users and I want each text box to have a tag name so that I can
export the data to xml.

<Document>
<Mytexboxes>
<Textbox1>
<Title>Document Content</Title>
<Subject>XML</Subject>
<Author>Me</Author>
</Mytexboxes>
....
</Document>
 
C

Cindy M.

Hi Sgraves,
I am parsing word documents to xml but when I open them in xml the file
structure is not define. I was thinking that maybe there is a way to give
the tags a name and then export each file.
Mmmmm. The correct way to do this is to attach a schema (xsd) to the
document, then insert nodes from the schema where you want to extract your
information. There are other ways, but this is certainly the most efficient,
as far as data extraction goes, because you can concentrate on your own
namespace.

If you don't want to go that route, then you need some kind of object in Word
that will give you an identifiable "name". You mention a "textbox", but there
are at least three different things in Word that carry that designation...

Assuming you mean a drawing object, then you need to assign a value to its
Name property, using VBA (there's no way to do that in the UI). Then it would
be in this element: v:shape id="TEST"

If you mean a formfield, then a formfield generates a bookmark and you might
be able to identify it by that. Keep in mind, however, that by default that
bookmark is generated IN the formfield, not around it, which makes it
difficult to locate the node you require.

You will not be able to use an ActiveX textbox.
I am creating text boxes that will be fill in with the information by
diffirent users and I want each text box to have a tag name so that I can
export the data to xml.

<Document>
<Mytexboxes>
<Textbox1>
<Title>Document Content</Title>
<Subject>XML</Subject>
<Author>Me</Author>
</Mytexboxes>
....
</Document>


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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