Check to see if field should be updated

B

Bonsai Bill

I have simple macros that generate captions and cross-references for tables,
figures and equations. I also have one, taken from Help, that updates all
fields. The problem is that I received files back from a publisher that
contains equations as a field object that MSWord XP doesn't like. When I run
ActiveDocument.Fields.Update Word overwrites the field with error message
"Error! Objects cannot be created from editing field codes."

Can someone please offer me a way to trap the error before it overwrites the
"bad" field and just have it bypass that field? Otherwise, I end up having to
recreate many equations.

Thanks for your time and help!
 
D

Doug Robbins - Word MVP

The caption and cross-reference fields will be SEQ and REF fields
respectively. Therefore, you could only update those types of fields by
running the following macro:

Dim afield As Field
For Each afield In ActiveDocument.Fields
If afield.Type = wdFieldRef Or afield.Type = wdFieldSequence Then
afield.Update
End If
Next afield

If however there are other types of fields that you do want to update, then
you may be better off modifying the code so that it checks to see if the
field is of the type that you do not want to update (possibly
wdFieldFormula) and only updates the fields that are not of that type.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

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