repeating a portion of a macro

T

Tony Logan

I have a Word document containing text and tables. Some of the
paragraphs begin with a bullet character, then a tab character, then a
sentence or two of text, then a paragraph mark. These bulleted
paragraphs sometimes appear alone, in groups of two, three, or more.

I'm trying to perform the following sequence of actions:
1) Find and Replace all bullets + tabs with the word "BULLET"
2a) Find each instance of the word BULLET
2b) Find the very next instance of a paragraph mark
2c) Replace that paragraph mark with the words "END BULLET" plus a
paragraph mark

Item 1 is simple enough, as a find & replace deals with it. But 2a-2c
are the stumpers. I suspect some sort of For Each/Next loop might be
the answer, but I'm not sure.

Thanks.
 
J

Jonathan West

Hi Tony

2a-2c can be done like this

Dim rngBullet As Range
Set rngBullet = ActiveDocument.Range(0, 0)
With rngBullet.Find
.Format = False
.Text = "BULLET"
.MatchCase = True
.Wrap = wdFindStop
Do While .Execute
rngBullet.Paragraphs(1).Range.Characters.Last.InsertBefore "END
BULLET"
rngBullet.Move Unit:=wdParagraph, Count:=1
Loop
End With
 

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