automating word

P

Peter

Ok this one is killing me. I'm trying to use the range object to select all
paragraph marks in a document. Then ensure all paragraph marks have no bold
or italic settings.
So I'm doing this (see below)...but I can't get it to select all it only
selects the first one found.
I know there is a way of doing this, but I'm struggling to recall.
Any help gratefully received!

Regards,

Peter

Set rngSearch = ActiveDocument.Content
With rngSearch.Find
.Text = "^p"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
rngSearch.Find.Execute
rngSearch.Select
rngSearch.font.bold = false
rngSearch.font.italic = false
 
J

Jonathan West

Hi Peter,

VBA doesn't deal with multiple selections in quite the same way as the user
interface. However, the following will do what you are trying to achieve

With ActiveDocument.Content.Find
.Text = "^p"
.Format = True
.ClearFormatting
.Replacement.Text = ""
.Replacement.ClearFormatting
.Replacement.Font.Bold = False
.Replacement.Font.Italic = False
.Forward = True
.Wrap = wdFindStop
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
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