![]() |
|
#2
|
||||
|
||||
|
You should be able to use something like:
Code:
Sub CleanupTables()
Application.ScreenUpdating = False
Dim Tbl As Table, Rng As Range, PrefWdthType As Long, PrefWwdthVal As Single, bFit As Boolean
For Each Tbl In ActiveDocument.Tables
With Tbl
Set Rng = .Range.Characters.First.Previous.Paragraphs.First.Range
If Rng.Text Like "Table [0-9]*" Then
Rng.ParagraphFormat.TabStops.ClearAll
bFit = .AllowAutoFit
.AllowAutoFit = False
PrefWdthType = .PreferredWidthType
PrefWwdthVal = .PreferredWidth
With Rng
.End = .End - 1
.ConvertToTable Separator:=vbTab, NumRows:=1, NumColumns:=1, Format:=wdTableFormatNone, ApplyHeadingRows:=True
With .Tables(1)
If PrefWwdthVal <> 9999999 Then
.PreferredWidthType = PrefWdthType
.PreferredWidth = PrefWwdthVal
End If
With .Range.Cells(1).Range
.Style = "Caption"
.ParagraphFormat.Reset
End With
End With
End With
.Range.Characters.First.Previous.Delete
.AllowAutoFit = bFit
End If
End With
Next
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
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 |
| Can I create a page number from a non-Heading style? | techwriter3k | Word | 9 | 09-25-2019 06:58 AM |
| Deleting Blank Space between table heading and table rows | Pete Jones | Word Tables | 5 | 01-22-2018 04:11 PM |
Heading row disappears from table styles when pasted table is selected
|
andrewballem | Word Tables | 2 | 11-12-2013 05:18 AM |
Create and save custom heading style
|
ubns | Word | 3 | 08-01-2012 09:42 PM |