![]() |
|
|
|
#1
|
|||
|
|||
|
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
Thanks M |
|
#2
|
|||
|
|||
|
Managed to 'fix' it myself with some Power Googling :-)
Code:
Sub Table5OnwardSwap()
Application.ScreenUpdating = False
Dim tblcount As Integer
Dim tbl As Table
For tblcount = 5 To ThisDocument.Tables.Count
Set tbl = ThisDocument.Tables(tblcount)
If tbl.Style = "Bad Table 1" Then
tbl.Style = "Grid Table 4 - Accent 1"
tbl.ApplyStyleRowBands = False
End If
Next
Application.ScreenUpdating = True
Set tbl = Nothing
End Sub
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Want to copy & paste a table underneath itself x no. of time, table found through style heading name
|
fly545 | Word VBA | 11 | 01-16-2020 05:53 PM |
| When changing table style in Word 2010, font size seems to change but doesn't show in new tables | heartsoulliving | Word | 1 | 12-07-2016 05:17 PM |
how to apply table style WITHOUT setting it as a table?
|
dylansmith | Excel | 9 | 05-16-2014 07:25 PM |
| Can't change color of text in table style | ABode | Word | 6 | 12-03-2013 07:45 AM |
| How to change style of text in table? | SCMiller | Word VBA | 1 | 04-24-2012 08:31 AM |