Find/Replace with Wildcards

S

supersub15

Hi there,

I'm trying to create a macro that would find an empty paragraph mark,
followed by a section break, and replace it with just the section
break.

With Selection.Find
.Text = "(^13)(^13^m)"
.Replacement.Text = "\2"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With

The macro is able to find the string alright, but it won't execute the
replacement. Is my code alright?

Thanks
Carlos
 
S

Stefan Blom

In the user interface, you can delete the paragraph mark by pressing the
Backspace key. But using Find and Replace doesn't seem to work even in the
user interface.

What are you trying to achieve? If you want to reduce the vertical space
occupied by the paragraph mark and section break, you can select and format
the whole paragraph mark in 1 pt font size, with zero spacing before and
after. In addition, you can format the whole thing as hidden.

-- 
Stefan Blom
Microsoft Word MVP




---------------------------------------------
"supersub15" wrote in message

Hi there,

I'm trying to create a macro that would find an empty paragraph mark,
followed by a section break, and replace it with just the section
break.

With Selection.Find
.Text = "(^13)(^13^m)"
.Replacement.Text = "\2"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With

The macro is able to find the string alright, but it won't execute the
replacement. Is my code alright?

Thanks
Carlos
 

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