Testing if GoTo next field succeeded

  • Thread starter christophercbrewster via OfficeKB.com
  • Start date
C

christophercbrewster via OfficeKB.com

I need to go to each field in a document and perform an action. When there
are no more fields, I want to end the loop. This seems similar to a find
operation, but how does the code know when there are no more fields? I don't
see a test for it. It could be something similar to "if selection.find.found"
or it could be "if selection.information = inField" etc. except that the
information property doesn't seem to detect fields. Thanks...

--
Christopher Brewster
Lockheed Martin, Eagan MN

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200911/1
 
P

Peter Jamieson

You might be able to compare the current field's index with (say)
ActiveDocument.fields.Count

Not sure how feasible that is, or how it might work given that the
document has multiple "Stories", each of which can contain fields.


Peter Jamieson

http://tips.pjmsn.me.uk
 
T

Tony Jollans

As Peter says, you will have to handle each Story separately, but within
each, you can use:

For Each F in Story_ref.Fields
...

and if you are only interested in fields in the main story then, more simply

For Each F in ActiveDocument.Fields
...
 

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