Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Apr 2003
    Location
    Kansas City, Missouri
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Resetting numbered lists in Word (Word 97/2000)

    What are some gotchas when programmatically setting the beginning number of numbered lists in Word?

    I know that when I record macros (my favored way of figuring out what code works best), I get code like:
    ListGalleries(wdNumberGallery).ListTemplates(6).Li stLevels(1).StartAt = 5

    But it seems that I am seeking out specific list galleries to use. For one user, this list gallery may be List Templates (6), but it could be different for another user, if I understand this correctly.

    Numbered lists are not exactly my forte, unfortunately. I'm having difficulty working with these. I want to create code that very simply takes the selection and sets the StartAt value based on user input. But it looks like I have a hard road to hoe. If anyone has any suggestions and pitfalls to share, I'd really appreciate it.

    Kevin

  2. #2
    3 Star Lounger
    Join Date
    Apr 2003
    Location
    Calgary, Alberta
    Posts
    208
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Resetting numbered lists in Word (Word 97/2000)

    I'm not experienced with VB/VBA... just learning myself... however, I just completed a project creating list templates and bought a book to help out... Writing Word Macros by Steven Roman... fortunately for you, the chapter on List Templates is online (free!)... here's the link: http://www.oreilly.com/catalog/writewordma...apter/ch17.html . As for your initial question about changing the starting number... is this something the user will be performing once in a specific document or multiple times? If it is multiple, you could end up with a nightmare document (probably more of a learning issue on useage of Word's Outline Numbering). What would happen is each time the numbering Start At was changed, numbering below will sequentially follow and above will not. So, say for instance the user needs to add a paragraph above one where they changed the StartAt value, but they want that paragraph to Start At... you see what I mean. I call them 'maps' everytime you visit the Gallery and change any value (whether indent, StartAt, etc.) you create a new map FROM THAT POINT FORWARD. All text above this will follow the previous map... this is why the document gets 'nightmarish' and very hard to modify. Hope this helps... trish

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

    Re: Resetting numbered lists in Word (Word 97/2000)

    Kevin,

    You're correct to observe that you can't rely on what the macro recorder produces in this case.
    It's not reliable to control numbering programatically using the ListGalleries number in any case.

    One way to control these things more reliably is to build all your numbering schemes programatically and name the list templates; you can then refer to the list templates by their name. Some folks here have tackled that, but I'm not among them! (there is a way to programatically control list templates that are not named, and which have not been created programatically, but topic for another post)

    In any event, the following seems to work, named list template or no - does this work for your application:

    Selection.Range.ListFormat.ListTemplate.ListLevels (1).StartAt = 5

    Gary

  4. #4
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Resetting numbered lists in Word (Word 97/2000)

    Hi Kevin,

    If your list template is named, you can use ListNum fields to manipulate the numbering.

    If it isn't named, you can name it now: Place your cursor somewhere in the list, and use
    Selection.Range.ListFormat.ListTemplate.Name="myNa me"
    (for example directly from the "immediate" window in the VBA editor)

    Now you can place a hidden ListNum field above the list (not in the first numbered paragraph, but somewhere above it):
    { LISTNUM myNamel 1s 4 }

    One user with WordXP told me Word crashed when he used this method, but I've never had problems with it in Word2000, and I'm not sure the crash was related to using ListNum fields in this way.

    I like this method because AutoNumbering is fine as long as the numbering is standard, but when lists are manipulated (restarted...), I like to see in the document what's going on, and the hidden ListNum fields allow that.

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16> Klaus

Posting Permissions

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