Jump to content

hello,everyone

 

I just be told I need to add the table contents for the papers I finished before.  For one or two files. It's easy, just select “Insert Table of Contents" under Table of Contents . But There are more than 20 files. God, do I have to do that one by one ?  Is there any way I can try to batch  insert table contents for many Word documents??

 

Any help will be appreciated!

 

Link to post
Share on other sites

To be honest, perhaps there is a way to script that, but you'll be done faster if you do the 20 ToCs by hand instead of waiting for a script. Just a hint. Then you are done with it.

Main System:

Anghammarad : Asrock Taichi x570, AMD Ryzen 7 5800X @4900 MHz. 32 GB DDR4 3600, some NVME SSDs, Gainward Phoenix RTX 3070TI

 

System 2 "Igluna" AsRock Fatal1ty Z77 Pro, Core I5 3570k @4300, 16 GB Ram DDR3 2133, some SSD, and a 2 TB HDD each, Gainward Phantom 760GTX.

System 3 "Inskah" AsRock Fatal1ty Z77 Pro, Core I5 3570k @4300, 16 GB Ram DDR3 2133, some SSD, and a 2 TB HDD each, Gainward Phantom 760GTX.

 

On the Road: Acer Aspire 5 Model A515-51G-54FD, Intel Core i5 7200U, 8 GB DDR4 Ram, 120 GB SSD, 1 TB SSD, Intel CPU GFX and Nvidia MX 150, Full HD IPS display

 

Media System "Vio": Aorus Elite AX V2, Ryzen 7 5700X, 64 GB Ram DDR4 3200 Mushkin, 1 275 GB Crucial MX SSD, 1 tb Crucial MX500 SSD. IBM 5015 Megaraid, 4 Seagate Ironwolf 4TB HDD in raid 5, 4 WD RED 4 tb in another Raid 5, Gainward Phoenix GTX 1060

 

(Abit Fatal1ty FP9 IN SLI, C2Duo E8400, 6 GB Ram DDR2 800, far too less diskspace, Gainward Phantom 560 GTX broken need fixing)

 

Nostalgia: Amiga 1200, Tower Build, CPU/FPU/MMU 68EC020, 68030, 68882 @50 Mhz, 10 MByte ram (2 MB Chip, 8 MB Fast), Fast SCSI II, 2 CDRoms, 2 1 GB SCSI II IBM Harddrives, 512 MB Quantum Lightning HDD, self soldered Sync changer to attach VGA displays, WLAN

Link to post
Share on other sites

The issue might be if you haven't used different styles for each title level. Word has automatic ToC maker, which works best when your titles each use own style. Which you can then quickly config.

 

20 documents doesn't sound that bad. Even if you'd need to do styles again. Try adjusting 45 images on 115 page document (my just finished Master's Thesis).

^^^^ That's my post ^^^^
<-- This is me --- That's your scrollbar -->
vvvv Who's there? vvvv

Link to post
Share on other sites

For that, the most quick way may create a macro to do that. Here is a VBA macro I find, try as below:

 

Sub InsertTOCForMultiDoc()
  Dim objDoc As Document
  Dim strFile As String, strFolder As String
 
  '  Initialization
  strFolder = "C:\Users\Public\Documents\New folder\Test1\"
  strFile = Dir(strFolder & "*.docx", vbNormal)
 
  '  Precess each document in the folder.
  While strFile <> ""
    Set objDoc = Documents.Open(FileName:=strFolder & strFile)
 
    Selection.InsertBreak Type:=wdSectionBreakNextPage
    Selection.HomeKey Unit:=wdStory
    With ActiveDocument
      .TablesOfContents.Add Range:=Selection.Range, RightAlignPageNumbers:= _
        True, UseHeadingStyles:=True, UpperHeadingLevel:=1, _
        LowerHeadingLevel:=9, IncludePageNumbers:=True, AddedStyles:="", _
        UseHyperlinks:=True, HidePageNumbersInWeb:=True, UseOutlineLevels:= _
        True.TablesOfContents(1).TabLeader = wdTabLeaderDots
      .TablesOfContents.Format = wdIndexIndent
    End With
    ActiveDocument.Sections(1).PageSetup.DifferentFirstPageHeaderFooter = True
    With ActiveDocument.Sections(2)
      .Footers(wdHeaderFooterPrimary).LinkToPrevious = False
      .Footers(wdHeaderFooterPrimary).PageNumbers.RestartNumberingAtSection = True
      .Footers(wdHeaderFooterPrimary).PageNumbers.StartingNumber = 1
    End With
    ActiveDocument.TablesOfContents(1).Update
 
    objDoc.Save
    objDoc.Close
    strFile = Dir()
  Wend
End Sub

 

And the details steps, see here


https://www.datanumen.com/blogs/3-ways-quickly-insert-table-contents-word-document/

 

Hope it works

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×