Changing settings on several user-defined table styles in one go

A

andreas

Dear Experts:

below macro alters the Background color settings for odd rows on a
user-defined table style (Word 2003).

I got two (2) other user-defined table styles (User-Defined-Table-
Style-normal and User-Defined-Table-Style_academic) which also should
acquire this altered background color settings. The stlyes have been
created independently from each other, that is, no style is based upon
another.

So, my QUESTION is:
how do I have to alter the code so that all the user-defined table
styles get the different background pattern color in one go?

I could copy the macro code and paste it one after the other changing
just the Table Style Name. But I am sure there is a more elegant way
to do this, using "Do-Loop".

Help is much appreciated. Thank you very much in advance.

Regards, Andreas



Sub ChangeTableStyle()
Dim styTable As Word.Style

Set styTable = ActiveDocument.Styles("User-Defined-Table-Style_1")
With styTable.Table
.RowStripe = 1
With .Condition(wdOddRowBanding)
.Shading.Texture = wdTextureNone
.Shading.BackgroundPatternColor = RGB(188, 188, 70)
End With

End With
End Sub
 
D

Doug Robbins - Word MVP

You could use:

Sub ChangeTableStyle()
Dim styTable As Word.Style
Dim arrStyles as variant

arrStyles =
Split("User-Defined-Table-Style_1|User-Defined-Table-Style_2|User-Defined-Table-Style_3",
"|)
For i = 0 to uBound(arrStyles)
Set styTable = ActiveDocument.Styles(arrStyles(i))
With styTable.Table
.RowStripe = 1
With .Condition(wdOddRowBanding)
.Shading.Texture = wdTextureNone
.Shading.BackgroundPatternColor = RGB(188, 188, 70)
End With
End With
Next i
End Sub

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
A

andreas

You could use:

Sub ChangeTableStyle()
Dim styTable As Word.Style
Dim arrStyles as variant

arrStyles =
Split("User-Defined-Table-Style_1|User-Defined-Table-Style_2|User-Defined-T­able-Style_3",
"|)
For i = 0 to uBound(arrStyles)
     Set styTable = ActiveDocument.Styles(arrStyles(i))
    With styTable.Table
        .RowStripe = 1
         With .Condition(wdOddRowBanding)
             .Shading.Texture = wdTextureNone
            .Shading.BackgroundPatternColor = RGB(188, 188,70)
         End With
    End With
Next i
End Sub

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com















- Show quoted text -

Hi Doug,

that's it! Thank you very much for your professional help. I really
appreciate it.

Regards, Andreas
 

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