Altering a style without modifying a table’s style?

M

MichaelB

Hello,

Using the below macro is there a way I can have it omit styles within
tables? I have a rather large document with several tables within which I do
not wish to alter. I do need to alter the “Normal†text within the document
to the “Paragraph 1†style but the Tables need to remain unchanged.

Any help would be greatly appreciated.
Thanks much..
Mike


Sub ReplaceExample()
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
'
.Style = "Normal"
.Replacement.Style = " Paragraph 1"
'
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
End With
Selection.Find.Execute replace:=wdReplaceAll
End Sub
 
J

Jay Freedman

Hi Michael,

First I'll ask: Within the tables, are there any cells that have
paragraph formatting (indents, hanging indents, space before/after, or
line spacing) that is manually applied rather than part of the
paragraph style? I'm _not_ talking about character formatting such as
bold or italic, only the things that are in the Format > Paragraph
dialog.

If there is no such manual formatting in tables -- if they're clean
Normal style -- then you can let the macro convert all the Normal to
Paragraph 1 style, and then change the tables back to Normal. To do
that, add this just before the End Sub statement:

Dim oTbl As Table
For Each oTbl In ActiveDocument.Tables
oTbl.Range.Style = ActiveDocument.Styles("Normal")
Next oTbl

If there is manual paragraph formatting that needs to be maintained,
that's a bit more complicated.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 

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