Generating Contents inside a Table?

  • Thread starter Thread starter Kim Finleyson
  • Start date Start date
K

Kim Finleyson

Hello! Does anyone know if there is a way to generate a table of contents
inside a table (I'm using Word 2000), such that each entry fits into exactly
one cell?

Here's why I ask: I have a long document with 24 different steps, formatting
as headings. I want a checklist at the front of the document with page
numbers. Next to each entry will be a box (using a symbol for this, set to
large font).

For alignment purposes, I like to use a table with borders turned off. I
have in the past used individual cross-references for this kind of thing but
it occured to me today that maybe there's a way to generate the contents
into a table without having to manually enter all those cross-references?

(By the way, I'm upgrading to Word 2003 so maybe I can do it there?)

Thanks!
Kim Finleyson
 
Hi Kim Finleyson

You can try the following code. It puts the TOC into a table. It then adds an extra
column (where you can put your checkboxes).

Public Sub PutTOCInTable()
Dim fldItem As Word.Field
Dim rngTOC As Word.Range
Dim tblNew As Word.Table
Dim boolFound As Boolean
Dim sngWidth As Single

' Locate the TOC field
For Each fldItem In ActiveDocument.Fields
If fldItem.Type = wdFieldTOC Then
boolFound = True
Exit For
End If
Next

' No TOC, then no go
If boolFound Then
Set rngTOC = fldItem.Result

' Usable page width for table
With ActiveDocument.PageSetup
sngWidth = .PageWidth - .LeftMargin - .RightMargin - .Gutter
End With

' Put TOC into a table
rngTOC.ConvertToTable Separator:=wdSeparateByParagraphs, NumColumns:=1, _
AutoFitBehavior:=wdAutoFitFixed

' Add new column
Set tblNew = rngTOC.Tables(1)
tblNew.Columns.Add tblNew.Columns(1)

With tblNew

' Column 1 = 10% of available page width
With .Columns(1)
.PreferredWidthType = wdPreferredWidthPercent
.PreferredWidth = 10
End With

' Column 2 = 90% of available page width
With .Columns(2)
.PreferredWidthType = wdPreferredWidthPercent
.PreferredWidth = 90
End With

' Resize table to use available page width
.PreferredWidthType = wdPreferredWidthPoints
.PreferredWidth = sngWidth
End With
End If
End Sub

HTH + Cheers - Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top