Results 1 to 9 of 9
  1. #1
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Indexing big doc (W97, WinNT4)

    This sounds awfully like Word's "document map". (ActiveWindow.DocumentMap = True)

    What would your listbox do that the user can't do with the document map?

    StuartR

  2. #2
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Indexing big doc (W97, WinNT4)

    Good question - I'll have a look, but I think the answer is, list them in alphabetical order! Unless there's a way to do this with Document Map?
    Beryl M


  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Indexing big doc (W97, WinNT4)

    Yes, I'm afraid I do need to be able to alphabetise it ...
    Beryl M


  4. #4
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Indexing big doc (W97, WinNT4)

    Edited by BerylM to simplify problem!

    I have been asked to find a way to make it easier to navigate around a big document (over 200 pages). Sometime ago someone wrote a program in WordBasic that creates a listbox and puts all the headings in it, alphabetically, with a second entry for that heading where there are subheadings. The listing therefore looks something like this:

    Debentures
    Security
    Security - Long term needs
    Security - overnight delivery
    Training

    However, this was all done manually - ie all the entries are simply typed in the VBE - any alterations have to be manually added to the code, and all the numbering of the items redone by hand, by changing each ID number after the change to get them in order again

    Needless to say, I would like to rewrite it so that the program goes through the document itself, picks up all the heading 1s, orders them alphabetically, puts in the entries with heading 2s and lists the results in the list box.

    If this box was then searchable it would be even better, but I'm not asking for the moon here. <img src=/S/innocent.gif border=0 alt=innocent width=20 height=20>

    Unfortunately I don't really know where to start, so if someone could point me in the right direction, I'd be very grateful.

    Many thanks
    Beryl M


  5. #5
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Indexing big doc (W97, WinNT4)

    There's a helpful discussion about sorting List boxes in post 66671. The only other thing you need to do is to add your headings to a list box, presumably with something like..


    <pre>for each paraNext in ActiveDocument.Content
    If paraNext.Style = ActiveDocument.Styles(wdStyleHeading1) Then
    Me.lstBoxHeadings.Add paraNext.Range.Text
    End If
    Next paraNext
    </pre>

    (Code just typed into the box without syntax checking)

    It's not clear to me whether you meant to include the Heading2s in the alphabetical sort, or to add them to the List Box after their Heading1s

    StuartR

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Indexing big doc (W97, WinNT4)

    It seemed that the Table of Contents was most of the way to what you want: you can specify the heading levels, they appear neatly indented, and the entries are clickable hyperlinks. But unfortunately, you cannot sort a TOC. So, in order to take as much advantage as possible of the hyperlinks, I made the attached procedure that works in Word 2000 (sorry, can't test in 97). It does this: (1) Make a TOC; (2) Strip the page numbers; (3) Copy out the hyperlinks to a list that looks like the TOC but is outside the TOC field; and (4) sort the new list (this part involves some trickery). It runs reasonably fast. It would be best if it could mark itself and, when the time came to re-run it, delete itself, but...it's late.
    Attached Files Attached Files

  7. #7
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Indexing big doc (W97, WinNT4)

    Sounds great, jscher, many thanks.

    However, unfortunately, the ToC in W97 does NOT have clickable hyperlinks! At least not as standard - if there's a way of making it do so I haven't found it ...
    Beryl M


  8. #8
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Indexing big doc (W97, WinNT4)

    With some futzing, I think I got it to where it will work in 97, but this version will not work properly in 2000, so my testing has involved some special looping. Let me know if it works for you.
    Attached Files Attached Files

  9. #9
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Indexing big doc (W97, WinNT4)

    Many thanks, jscher! I'm tied up with something else right now, but next week I'll check it out.

    Have a nice Easter! <img src=/S/cool.gif border=0 alt=cool width=15 height=15>
    Beryl M


Posting Permissions

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