View Single Post
 
Old 05-01-2018, 06:04 AM
gmaxey gmaxey is offline Windows 7 32bit Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Or why don't you let Word use it own will to create the TOC and then use your will (aka macro) to make a table out of the TOC:

Code:
Sub ScratchMacro()
Dim oRng As Range
Dim oTbl As Table
  Set oRng = Selection.Fields.Add(Selection.Range, wdFieldTOC).Result
  oRng.Fields(1).Unlink
  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
  End With
  oRng.Select
  Selection.Collapse wdCollapseEnd
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote