Macro help needed

C

Can't Unlink

I need to unlink merge fields from an RTF document to
import into another application. I can unlink the merge
fields from the body of the document fine. I cannot get
the merge fields from the header to unlink. What
statement do I need to do that?

Thank you for any assistance you can offer.
 
J

Jezebel

To reference all the fields in a document, whatever their location, you need
to iterate the StoryRanges collection. Headers might be your only issue at
the moment, but you would have a similar problem if you had fields in
textboxes and footnotes. Same applies to updating fields. This is the method
I use:

Dim pRange as Word.Range

For each pRange in ActiveDocument.StoryRanges

Do
pRange.Fields.Unlink (or pRange.Fields.Update, etc)
set pRange = pRange.NextStoryRange
Loop until pRange is nothing

Next
 

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