View Single Post
 
Old 10-21-2019, 03:19 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Charles is right but you can retrofit a table of contents after refreshing it to do basically what you are asking. The following macro could be used to refresh your TOC and then compact it.
Code:
Sub CompactTOCUpdater()
  Dim aRng As Range, aTOC As TableOfContents
  Set aTOC = ActiveDocument.TablesOfContents(1)
  Set aRng = aTOC.Range
  aTOC.Update
  With aRng.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "^t"
    .Replacement.Text = ", "
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Execute Replace:=wdReplaceAll
    .Text = "^p"
    .Replacement.Text = " – "
    .Execute Replace:=wdReplaceAll
  End With
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote