![]() |
#15
|
|||
|
|||
![]()
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 |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
boxhamster | Word | 5 | 08-15-2015 03:25 PM |
LaTeX style table of contents in MS Word | MichaelHenrotte | Word | 1 | 11-23-2014 03:16 AM |
![]() |
Jetheat | Word | 4 | 12-15-2013 03:54 PM |
How to have this Heading – Table of contents style? | Jamal NUMAN | Word | 0 | 01-13-2011 06:02 PM |
Word 2003 Table of Contents Error Message | ktcolburn | Word | 1 | 10-30-2005 06:14 PM |