How to create the range between two field codes?

R

Robin Tucker

Consider the following field codes:

«SECTION_START»

....
Some text
....
Maybe an image
....

«SECTION_END»

How is it possible for me to create a range starting from the end of the
section_start mergefield and end at the section_end merge field start?

At present, I'm writing the following:

Dim theRange As Word.Range

theRange.Start = theFirstField.Result.End + 1
theRange.End = theSecondField.Result.Start - 1

However, it always seems that the range contains the second field code. All
I want is the stuff inbetween, NOT including the field codes.

Thanks for any tips you can give me on this,




Robin
 
R

Robin Tucker

Something like this seemed to work in the end:

theRange = theFirstField.Result
theRange.MoveStart(Word.WdUnits.wdParagraph, 1)
theRange.End = theSecondField.Result.End
theRange.MoveEnd(Word.WdUnits.wdParagraph, -1)
 

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