View Single Post
 
Old 05-02-2018, 01:23 AM
NevilleT NevilleT is offline Windows 7 64bit Office 2003
Novice
 
Join Date: Mar 2015
Posts: 29
NevilleT is on a distinguished road
Default

Brilliant. All working now. Added a few formatting things to it. This is the final code. Thanks to all who helped.

Sub ScratchMacro()
Dim oRng As Range
Dim oTbl As Table
Set oRng = Selection.Fields.Add(Range:=Selection.Range, Text:="TOC \o 4-4").Result
Set oTbl = oRng.ConvertToTable(vbTab)
With oTbl
.Rows.Add BeforeRow:=oTbl.Rows(1)
.Cell(1, 1).Range.Text = "Topic"
.Cell(1, 2).Range.Text = "See Page"
.Columns(2).Select
Selection.ParagraphFormat.Alignment = wdAlignParagraphRight
.Borders.OutsideLineStyle = wdLineStyleSingle
.Columns(1).Width = 290
.Columns(2).Width = 80
.Rows(1).Range.Bold = True
.Rows(1).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
.Rows(1).Shading.BackgroundPatternColor = wdColorGray25
End With
oRng.Select
Selection.Collapse wdCollapseEnd
lbl_Exit:
Exit Sub
End Sub
Reply With Quote