PDA

View Full Version : [SOLVED:] Table of Contents with multiple page numbers?



jmuir
01-09-2019, 01:34 PM
I am making a legal transcript template. I need to have a table of contents that has:

WITNESS NAME D X Re-D Re-C Voir dire
Name ## ## ## ## ##


I cannot figure out how to have a table of contents with multiple pages for that table. I tried to make multiple table of contents with columns, but I couldn't hide the text for the second and third columns.

Currently I pull the witness name from a cross-reference heading, and the page numbers from the cross-reference headings. Sometimes a witness doesn't have page numbers in all columns.

Can you help me???

macropod
01-09-2019, 01:57 PM
Your description suggests you need an Index, not a Table of Contents. In any event, a Table of Contents cannot output multiple page #s for a given entry.

jmuir
01-09-2019, 02:34 PM
Hmm. I will work on that. It appears like it should work. I may be back if I can't figure out how to tweak it just right, but I'll do my research first!

jmuir
01-09-2019, 03:15 PM
Okay. Index is the answer.
I need multiple indexes with "\f" switch, which I can figure out. Where I'm hung up at is I'm using VBA to have pull info from a userform to automatically "mark" the index. How do I make the switch be part of the VBA code?

ActiveDocument.Indexes.MarkEntry Range:=Selection.Range, Entry:= _
Me.wname.Text, EntryAutoText:=Me.wname.Text, _
CrossReference:="", CrossReferenceAutoText:="", BookmarkName:="", Bold:= _
False, Italic:=False

I tried to put it with the "Entry:=" but that produced an error.


Also, I would like to fine-tune the index in a few ways:

Remove comma after name
Place each page number after a tab or somehow standardize the format

Thank you so much!

macropod
01-09-2019, 04:54 PM
Index is the answer.
I need multiple indexes with "\f" switch, which I can figure out.
Try:

ActiveDocument.Indexes.MarkEntry Range:=Selection.Range, _
Entry:=Me.wname.Text, EntryAutoText:=Me.wname.Text
Selection.Fields(1).Code.InsertAfter "\f"

Also, I would like to fine-tune the index in a few ways:
Remove comma after name
Place each page number after a tab or somehow standardize the format
I see no reference to a comma elsewhere in this thread, so it's not apparent what you mean. If it's on the userform, you might change:
Me.wname.Text
to something like:
Replace(Me.wname.Text, ",","")
As for the page #s, the Index ordinarily separates them with a comma. You can define the page # separator via the INDEX field's \l switch.

jmuir
01-09-2019, 05:49 PM
I got the switch to work!




Private Sub butokay_Click()


With ActiveDocument
Selection.Paragraphs.add
Selection.Style = ActiveDocument.Styles("Heading 2")
Selection.Range.Text = UCase(cmbttype.value)
End With


ActiveDocument.Fields.add _
Range:=Selection.Range, _
Type:=wdFieldEmpty, _
Text:="XE """ & Me.wname.Text & """ \f """ & Me.cmbparty.Text & """", _
preserveformatting:=False


Unload Me
End Sub


The comma is in the Index itself:

First Last, ##, ##

I've figured out how to remove the comma between the page numbers and replace with spaces, but not the comma after the Last name.

Also, the index sort automatically alphabetically. I would like it sorted by chronological order. Any ideas for that?

macropod
01-09-2019, 06:30 PM
In that case, what you're referring to is the INDEX field's entry/page # separator, which can be controlled via the \d switch.

As for the sorting, you'd need something in the XE fields that would support that. It's not apparent, though, where any dates might be coming from.

jmuir
01-09-2019, 09:12 PM
By chronological, I mean the order they are entered into the transcript. I figure I could use ";" then add a digit or letter, but that would be manually appending to the index field entry because I don't know how to force it to do "witness name;1" then the next entry would be "witness name; 2" for a different witness's name. Of course I'd still have to figure out WHERE to put that in this code, but I can do trial and error. I just don't know how to force it to do it automatically.

As a work around, I could have a drop down box on the userform and they have to select a witness number. Then I would build that into the XE code. That would work, but it's not ideal.

Text:="XE """ & Me.wname.Text & """ \f """ & Me.cmbparty.Text & """", _
preserveformatting:=False


In that case, what you're referring to is the INDEX field's entry/page # separator, which can be controlled via the \d switch.

As for the sorting, you'd need something in the XE fields that would support that. It's not apparent, though, where any dates might be coming from.