View Single Post
 
Old 01-08-2021, 07:14 AM
mc1903 mc1903 is offline Windows 10 Office 2016
Novice
 
Join Date: Jan 2019
Posts: 8
mc1903 is on a distinguished road
Default Change Table Style from Table 5 Onwards.

Hi,

I am looking to swap the table style for table #5 onwards only if it matches a specific style.

This changes the style for ALL tables with using the 'Bad Table 1'; which includes tables 2 & 3 which I need to keep as the 'Bad Table 1' style (long boring story).

I am sure it is something stupid; but my VBA skills are basic and I am frankly amazed I got this far!

Anyone have 10 mins to help me please?

Code:
Sub Table5OnwardSwap()
    Application.ScreenUpdating = False
    Dim tblcount As Integer
    Dim tbl As Table
    For tblcount = 5 To ActiveDocument.Tables.Count
        For Each tbl In ThisDocument.Tables
            If tbl.Style = "Bad Table 1" Then
                tbl.Style = "Grid Table 4 - Accent 1"
                tbl.ApplyStyleRowBands = False
            End If
        Next
    Next
    Application.ScreenUpdating = True
    Set tbl = Nothing
End Sub
Any pointers will be appreciated.

Thanks
M
Reply With Quote