Consulting

Results 1 to 8 of 8

Thread: Table of Contents with multiple page numbers?

  1. #1
    VBAX Regular
    Joined
    Jan 2019
    Posts
    6
    Location

    Table of Contents with multiple page numbers?

    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???

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    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.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    VBAX Regular
    Joined
    Jan 2019
    Posts
    6
    Location
    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!

  4. #4
    VBAX Regular
    Joined
    Jan 2019
    Posts
    6
    Location
    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!

  5. #5
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Quote Originally Posted by jmuir View Post
    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"
    Quote Originally Posted by jmuir View Post
    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.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  6. #6
    VBAX Regular
    Joined
    Jan 2019
    Posts
    6
    Location
    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?
    Last edited by macropod; 01-09-2019 at 06:26 PM. Reason: Added code tags

  7. #7
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    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.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  8. #8
    VBAX Regular
    Joined
    Jan 2019
    Posts
    6
    Location
    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
    Quote Originally Posted by macropod View Post
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •