I'm afraid I oversimplified my example. The Word document I'm working
with is a lot more complex than I described. It wouldn't neatly fit
into a database structure. Each "Level 3" is actually a detailed
description of a web page, complete with screen shot, tables, event
descriptions, and data access. Out of that whole mess, I just want to
pluck every line that starts with "Stored Procedure Name:" and paste
that line into a new document, along with the name of the screen where
it appears. (The screen name is the Level 3 Heading).
Here is how I'm doing it now:
Start at the top
Go to the next heading
If that heading isn't level 3, go to the next heading.
If it IS level 3, then:
1) Select the heading text and assign it to strCurrentHeading.
2) Select the whole body under this heading and paste it into a new
screen, call it TempScreen1.
Then search TempScreen1 for "Stored Procedure Name:" Select that whole
line and paste it into a third document, call it StoredProcList.doc,
preceded by strCurrentHeading.
Keep doing that until "Stored Procedure Name:" isn't found.
Then erase everything from TempScreen1 and go back to the main
document and find the next level 3 heading.
Repeat until there are no more headings.
The problem is, it's messy and prone to error, especially the bit
about selecting the whole section. Here's how I want to do it:
Start at the top
Search for "Stored Procedure Name:"
Determine the Selection.Level3HeadingName and assign it to
strCurrentHeading.
Select the whole line and copy it.
Switch to StoredProcList.doc. Paste in strCurrentHeading and the name
of the stored procedure.
Switch back to main document, lather, rinse, repeat.
That would work beautifully, assuming that something like
Selection.Level3HeadingName exists. Does it?
> What you're after is certainly do-able in principle; but quite a lot of
> work, and there are, in any case, any number of applications already around
[quoted text clipped - 49 lines]
>
> - Show quoted text -
Jezebel - 14 Feb 2007 04:13 GMT
You could do it like this --
1. Iterate the paragraphs of the document.
2. If the paragraph is a level-3 heading, save it strCurrentHeading.
3. Else if the paragraph begins "Stored Procedure Name:", write
strCurrentHeading & paragraph range into your second document
4. Ignore all other paragraphs
> I'm afraid I oversimplified my example. The Word document I'm working
> with is a lot more complex than I described. It wouldn't neatly fit
[quoted text clipped - 94 lines]
>>
>> - Show quoted text -
MarsBar - 14 Feb 2007 18:50 GMT
Very nice. That will work. Thanks.
(But I'd still like to have something like
Selection.CurrentOutlineHeading, if any Word develoopers are
listening.)
> You could do it like this --
>
[quoted text clipped - 108 lines]
>
> - Show quoted text -