Select Single Field in Word XP

P

pavan

Hi All,
My word document has many fields in it (analogous to XML nodes in
Office 2003 and above). I need to read information from some of them.
Right now I loop through the activeDocument.Fields collection to get
the required information. this is, quite obviously, a perf hit. Like
activeDocument.SelectSingleNode or acitveDocument.SelectNodes methods
present in Office 2003, is there anything that I can make use of in
Office XP and helps reduce the perf hit?

Appreciate quick pointers as it is little urgent
Regards
TIA
Pavan
 
C

Cindy M.

Hi Pavan,
My word document has many fields in it (analogous to XML nodes in
Office 2003 and above). I need to read information from some of them.
Right now I loop through the activeDocument.Fields collection to get
the required information. this is, quite obviously, a perf hit. Like
activeDocument.SelectSingleNode or acitveDocument.SelectNodes methods
present in Office 2003, is there anything that I can make use of in
Office XP and helps reduce the perf hit?
There is no exact equivalent, no. Unless you're using form fields,
which have a Name property.

Standard approach in Word for identifying things is to select them,
then Insert/Bookmark. That let's you do something like:

Dim fld as Word.Field = doc.Bookmarks("NameOfBookmark").Range.Fields(1)

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 :)
 
P

pavan

Hi Cindy,
Thanks for the reply!

I'm not using FormFields. I'm using Fields. So, does it mean that the
only way to get to a field is to parse through the collection of
fields?

Thanks
 
C

Cindy M.

Hi Pavan,
So, does it mean that the
only way to get to a field is to parse through the collection of
fields?
Unless you use bookmarks, as described in my previous reply, yes.

Or, unless you can narrow down the range you want to process for
fields. Such as the second section in a document. Or from the
third table onwards. Anything that can restrict the range so that
you can loop through Range.Fields instead of doc.Fields

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