Results 1 to 9 of 9
  1. #1
    New Lounger
    Join Date
    Jan 2001
    Location
    Lafayette, Indiana, USA
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Creating an index referencing line numbers

    This is a pretty obscure request. May some of you will
    view it as a challenge.

    I have a document which has each line numbered (using Word's line numbering feature). I want to create an index for the document, but instead of the index showing the page numbers that the indexed word appears on, I want the index to show the line numbers.

    Can Word do this for me (perhaps with some help from Visual Basic)? Otherwise, I'll have to do all of it the manual way.

    Thanks for your suggestions and interest!

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Creating an index referencing line numbers

    Yes it's a pretty obscure request.
    Yes it's an interesting challenge.
    Yes Word can do this for you (with some help from VBA).
    Here's how:

    When you mark your index entries in the document (I don't know much about Indexes, so I'm assuming this is done by means of the Mark Index Entry dialog which can be accessed via Insert>Index and Tables etc.):

    Under Options click on the Cross-Reference option button.
    Replace the default text ("See") with "xln" (that's lower case XLN) - this is a marker for the macro to find later.

    Then before inserting the Index proper, run the following macro - this looks for the "xln" reference in each XE (Index) field, and replaces it with the line number for the start of the marked text.

    <pre>Sub IndexWithLineNumbers()
    'Gary Frieder February 2001 Word 2000
    'Purpose: Enable display of line numbers for index entries
    'To set up in Document: When marking Index entries, set Option to
    ' cross-reference,and replace "See" with "xln"

    Dim objCurDoc As Document
    Dim lngLineNum As Long
    Set objCurDoc = ActiveDocument
    ActiveWindow.View.ShowHiddenText = True
    Do
    With Selection
    .HomeKey Unit:=wdStory
    With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "xln"
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchCase = True
    .MatchWholeWord = True
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Execute
    If .Found Then
    With Selection
    lngLineNum = .Information(wdFirstCharacterLineNumber)
    .TypeText (Str$(lngLineNum))
    End With
    Else
    GoTo Exit_IndexWithLineNumbers
    End If
    End With
    End With
    Loop
    Exit_IndexWithLineNumbers:
    With ActiveWindow.View
    .ShowHiddenText = False
    .ShowAll = False
    End With
    End Sub
    </pre>

    PS: close readers will note that I found a quick use for the Find/Replace Do..Loop which Phil R. shot down last night.[img]/w3timages/icons/cool.gif[/img]

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Creating an index referencing line numbers

    Nice! Can I steal^H^H^H^H^H borrow this for my Indexer tool and give you credit?

  4. #4
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Creating an index referencing line numbers

    Sounds OK to me.

    Here's a Lionel Trilling quote which Ken Getz used at the start of the foreword of his VBA Developer's Handbook:

    "Immature artists imitate; mature artists steal."

    Maybe nowadays this would be called "appropriation". Adds an additional layer of meaning to "found objects", eh?

  5. #5
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Creating an index referencing line numbers

    Hi Gary:

    >>PS: close readers will note that I found a quick use for the Find/Replace Do..Loop which Phil R. shot down last night.<<

    Must be another Phil R.[img]/w3timages/icons/grin.gif[/img] This one[img]/w3timages/icons/clown.gif[/img]would never shoot down one of your ideas[img]/w3timages/icons/nope.gif[/img].

  6. #6
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Creating an index referencing line numbers

    >"found objects"

    This sounds like a reference to something I ought to know in VB/VBA.

    What is a "found object" in our environment? Does it have a meaning?

  7. #7
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Creating an index referencing line numbers

    Nah, these were art world buzzwords maybe 20-30 years ago (don't know too much about this) - "found objects" were objects the artist found in his environment and incoporated into his art. Extending this from physical artifacts to cultural ones, a found object could be some element of for instance, mass culture, which the artist could 'appropriate' and reuse in a context which commented on its original cultural meaning blah blah blah.

    I was just playing around with this and the idea of appropriating code objects (particularly ones that deal with the "Find Object"<G>)....

  8. #8
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Found Objects

    *** Geoff W URL Added ***

    A recent example being <A target="_blank" HREF=http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Cat=&Board=wrd&Number=17072&Search =true&Forum=wrd&Words=17072&Match=MessNum&Searchpa ge=0&Limit=25&Old=2weeks&Main=16673>Bar Tabs</A> ([Post#: 17072 / re: 16673 ] )[img]/w3timages/icons/smile.gif[/img]

    Andrew C

  9. #9
    New Lounger
    Join Date
    Jan 2001
    Location
    Lafayette, Indiana, USA
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Creating an index referencing line numbers

    Thanks so much for your help! I've been down with the
    flu since the post, so haven't had a chance to try it.

    Thanks again!

Posting Permissions

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