Delete from "Found" item to the next Continuous Section Break

S

Sophia

Hello ...

I have rtf files comprised of a number of documents merged together.

If I click the Paragraph button on the tool bar down, I see that each
of the merged documents in the rtf file is separated by a "Continuous
Section Break".

Each of the merged documents in the rtf contains a number of headings,
such as "TITLE:", "ABSTRACT:" etc. followed by some text. In some of
the merged documents there is a heading called "FINAL:"

Something like this:

For the entire rtf document:

For each instance of the word "FINAL:",
Delete all text until the next Continuous Section Break.

Next Section

Thanks for your help ...
 
D

DA

Hi Sophia

Try the following macro. It mirrors your pseudo code, but
I'd be carefull that you're not going to have the search
string "FINAL:" in unwanted parts of your document.

-----------
Private Sub FindDEL()
Dim mySCTN As Section

With Selection.Find
For Each mySCTN In ActiveDocument.Sections
.Forward = True
.ClearFormatting
.MatchCase = True
.Wrap = wdFindContinue
.Execute FindText:="FINAL:"
If .Found Then
Selection.Extend
.Execute FindText:="^b"
If .Found Then Selection.Delete
End If
Next
End With
End Sub
 
S

Sophia

Dennis ...

I'm on my way to test this out right now.

I can see you've had a busy night in
microsoft.public.word.vba.beginners, for which I'm sure there are many
happy folks here.

Thank you very much,

Sophia
 
S

Sophia

Dennis ...

Well ... you've reduced my last 3 hours hopeless work into a handful
of lines that works perfectly.

I'm really grateful ... thanks,

Sophia
 

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