Find and Replace Table Styles

D

David

Is it possible to find and replace table styles within Word 2007? I
have a number of small tables in a section of my document that I want
to convert from using a built in table style to a custom style that I
have subsequently defined. Going into the standard Find/Replace
dialog gives options to search on paragraph styles, but not for table
styles. Is this possible, outside of opening up the XML and tweaking
things outside of Word?

Thanks for the help!

David
 
S

Stefan Blom

The following macro should work:

Sub FindAndReplaceTableStyles()
Dim t As Table
For Each t In ActiveDocument.Tables
If t.Style.NameLocal = "Light Shading - Accent 3" Then
t.Style = "Medium Shading 1"
End If
Next t
End Sub

The example applies the "Medium Shading 1" style to all tables in the
*document* that are currently using the "Light Shading - Accent 3" style. Of
course, you will have to change the style names to the ones that are
relevant for you.

If you want to replace the table styles in the *selection*, use
Selection.Tables instead of ActiveDocument.Tables in the code.

See also http://www.gmayor.com/installing_macro.htm.

--
Stefan Blom
Microsoft Word MVP


in message
news:[email protected]...
 
D

David

The following macro should work:

Thanks, Stefan. That did the trick. My first tentative step into
macro-izinig my default template has been taken!

David
 
S

Stefan Blom

I'm glad I could help.

--
Stefan Blom
Microsoft Word MVP


in message
The following macro should work:

Thanks, Stefan. That did the trick. My first tentative step into
macro-izinig my default template has been taken!

David
 

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