View Single Post
 
Old 05-01-2018, 06:14 PM
gmaxey gmaxey is offline Windows 7 32bit Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,427
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

The reason for converting the TOC to a table is because the original poster wants a table in a specific format not a TOC.

Guessed, I think this could resolve the issue you mentioned. Just don't delete any field:

Code:
Sub ScratchMacro()
Dim oRng As Range
Dim oTbl As Table
  Set oRng = Selection.Fields.Add(Selection.Range, wdFieldTOC).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
  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