Search & Replace Styles

J

JohnTheTemp

I've created a macro to Search & Replace Styles and it simply doesn't work.

I've noticed that the Search & Replace dialog box afterwards looks weird.
Instead of, say Style "N-1", it has "N-1" and a description of the formatting
(eg, "Border: Top...").

Any explanations? Any workaround?

Thanks.
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?Sm9oblRoZVRlbXA=?=,
I've created a macro to Search & Replace Styles and it simply doesn't work.

I've noticed that the Search & Replace dialog box afterwards looks weird.
Instead of, say Style "N-1", it has "N-1" and a description of the formatting
(eg, "Border: Top...").

Any explanations? Any workaround?
Any code? Any version information?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
J

JohnTheTemp

Sorry...

Word 2003

Code:

N_Style = "N-" & StyleNumber
BASS_Style = "BASS PARA NUM [" & StyleNumber & "]"

Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles(N_Style)
Selection.Find.ParagraphFormat.Borders.Shadow = False
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Style = ActiveDocument.Styles( _
BASS_Style)
Selection.Find.Replacement.ParagraphFormat.Borders.Shadow = False
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll-

JohnTheTemp
 
K

Klaus Linke

Hi John,

Delete the lines containing ".ParagraphFormat.Borders.Shadow = False".

You've run into a combination of bugs:
First, the macro recorder put in stuff you did not specify about the
paragraph borders.
Second, although your paragraphs likely do not have a border shadow and the
recorded macro searches for paragraphs that do not have a border shadow, the
code does not find what it should find.

Regards,
Klaus



JohnTheTemp said:
Sorry...

Word 2003

Code:

N_Style = "N-" & StyleNumber
BASS_Style = "BASS PARA NUM [" & StyleNumber & "]"

Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles(N_Style)
Selection.Find.ParagraphFormat.Borders.Shadow = False
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Style = ActiveDocument.Styles( _
BASS_Style)
Selection.Find.Replacement.ParagraphFormat.Borders.Shadow = False
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll-

JohnTheTemp


Cindy M -WordMVP- said:
Hi =?Utf-8?B?Sm9oblRoZVRlbXA=?=,

Any code? Any version information?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
 

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