Find select until next occurance?

C

Co

Hi All,

I need to cut a word doc that consists of several parts into smaller
documents.
The doc starts with SUBJECT and then some text, a new part again
starts with SUBJECT.
So I'm trying to search for the word SUBJECT and then highlight all
the text after that until
it finds SUBJECT again. The highlighted text must be copied into a new
document.
I managed to find the word SUBJECT but then I need to know how many
lines until the next
SUBJECT. Can that be done?

Selection.Find.ClearFormatting
Selection.Find.Font.Size = 16
With Selection.Find
.Text = "SUBJECT"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveDown Unit:=wdLine, Count:=15, Extend:=wdExtend

Marco
 
M

MyVeryOwnSelf

I need to cut a word doc that consists of several parts into smaller
documents.
The doc starts with SUBJECT and then some text, a new part again
starts with SUBJECT.

Here's one way, but it isn't what you had in mind, and it doesn't work for
all documents. Also, it's not the best way if you need to process lots of
documents.

First, use
Edit > Replace

Under "Find what" and under "Replace with" put "SUBJECT".

With the cursor in "Replace with"
- Click "More"
- In the "Format" pull-down click "Style"
- In the Style list, choose Heading1

Click "Replace All." This makes each SUBJECT line like a chapter heading.

Then, you can
View > Outline
Select all
Click the minus sign in the outline toolbar

This collapses the outline so there's one line representing each of the
smaller documents. You can then (for example) copy each of these lines into
a new blank document and change the style of the first line back to the way
it was.
 

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