Robustly fetching the range between two field codes.

R

Robin Tucker

Say, for example, I have a single page looking something like this:


<<SECTION_START>>
--------------------------------------------------------------
| Database ID | Asset Title
|
--------------------------------------------------------------
| <<ASSET_ID>> | <<ASSET_NAME>> |
--------------------------------------------------------------
<<SECTION_END>>


How is it possible to remove the field codes <<SECTION_START>> and
<<SECTION_END>>, without leaving blank lines above and below, so that when I
perform a directory merge I end up with one big table, rather than something
like the following:

--------------------------------------------------------------
| Database ID | Asset Title
|
--------------------------------------------------------------

--------------------------------------------------------------
| 10234 | Primary Crusher
|
--------------------------------------------------------------

--------------------------------------------------------------
| 10235 | Secondary Crusher
|
--------------------------------------------------------------

What I want, is something that looks like this:

--------------------------------------------------------------
| Database ID | Asset Title
|
--------------------------------------------------------------

| 10234 | Primary Crusher
|
--------------------------------------------------------------
| 10235 | Secondary Crusher
|
--------------------------------------------------------------

To enlarge a little more, I have report "templates", within which the user
can embed "SECTION_START" and "SECTION_END" tags. My code then goes through
the template, splitting it into separate documents (everything between
SECTION_START and SECTION_END). These documents are then mail-merged with
the data source, before being re-combined into the finished report. This
allows me to do a main report section, on a given set of records and then a
summary section on another, different set of records. At present I'm
finding the range between the tags like so:

' The indices of the start and end section tags (index within the fields
collection for the document)

Dim theSectionStartIndex, theSectionEndIndex as integer

...
... find the section start and end tag indices
...

theRange = m_LoadedDocument.Fields.Item(theSectionStartIndex).Result
theRange.Collapse(Word.WdCollapseDirection.wdCollapseStart)
theRange.MoveStart(Word.WdUnits.wdCharacter, -1)

theRange.End =
m_LoadedDocument.Fields.Item(theSectionEndIndex).Result.End
theRange.MoveEnd(Word.WdUnits.wdCharacter, 1)

But when merged, this range results in the split table above, rather than a
combined one.

Thanks for any hints you can give me about this.




Robin
 
W

Word Heretic

G'day "Robin Tucker" <[email protected]>,

After removing the field code, check the para for < n chars (1 is
needed for the para mark as a minimum) and if so, delete the mother.

Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


Robin Tucker reckoned:
 

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