I would like to take the formatted text between two fields and place it into
another document.

So far, writing something like this:

theRangeSource = theFirstField.Result
theRangeSource.Collapse(Word.WdCollapseDirection.wdCollapseEnd)
theRangeSource.End = theSecondField.Result.Start

theRangeDestination.FormattedText = theRangeSource.FormattedText

does *not* work correctly. I get bits of the field codes copied into the
second document.

I would either like all formatted text *between* the two fields, or all
formatted text *including* the two fields placed into my second document
(theRangeDestination).

Note: I cannot use the application "Selection" as this is "unsafe" for the
purposes of running my reporter in the background while people are possibly
working with word in the foreground.

How can I do this?


Thanks



Robin

Re: Copying the formatted text between two fields? by Robin

Robin
Fri Oct 22 11:16:57 CDT 2004


this works (it includes fields):

theRangeSource = theDocument.Range(theFieldStart.Code.Start - 1,
theFieldEnd.Result.End + 1)

this also works (excluding fields):

theRangeSource = theDocument.Range(theFieldStart.Result.End + 1,
theFieldEnd.Code.Start - 1 )

"Robin Tucker" <idontwanttobespammedanymore@reallyidont.com> wrote in
message news:clbaou$524$1$8302bc10@news.demon.co.uk...
>I would like to take the formatted text between two fields and place it
>into another document.
>
> So far, writing something like this:
>
> theRangeSource = theFirstField.Result
> theRangeSource.Collapse(Word.WdCollapseDirection.wdCollapseEnd)
> theRangeSource.End = theSecondField.Result.Start
>
> theRangeDestination.FormattedText = theRangeSource.FormattedText
>
> does *not* work correctly. I get bits of the field codes copied into the
> second document.
>
> I would either like all formatted text *between* the two fields, or all
> formatted text *including* the two fields placed into my second document
> (theRangeDestination).
>
> Note: I cannot use the application "Selection" as this is "unsafe" for the
> purposes of running my reporter in the background while people are
> possibly working with word in the foreground.
>
> How can I do this?
>
>
> Thanks
>
>
>
> Robin
>