Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Resetting a number in the middle of a list (Word 2003 VBA)

    You should declare ListLev as ListLevel instead of as Long.

  2. #2
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Resetting a number in the middle of a list (Word 2003 VBA)

    Sorry!! I did not name that variable well at all.

    The ListLev variable is actually the list. I will edit my original post and rename to "List1". I was trying to follow an example I found in the online help by setting this.

    Sorry for the confusion, and please help!!

    Thanks!!
    Troy

  3. #3
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Resetting a number in the middle of a list (Word 2003 VBA)

    <P ID="edit" class=small>(Edited by TroyWells on 06-Sep-06 19:34. )</P>I am trying to reset a list item number from 1 to 3 (or another number I calculate from a variable) in the middle of a list. Do to the dummy restart styles I have at the beginning of my list and how I have to use them, the numbers are restarting prematurely. Calculating the variable is no problem. Resetting the number is. I have tried using the following code:

    Dim List1 As Long
    Dim ListNumberBefore as Integer

    Set List1 = ListGalleries(wdOutlineNumberGallery).ListTemplate s(Selection.Range.ListFormat.ListTemplate.Name).Li stLevels(Selection.Range.ListFormat.ListLevelNumbe r)
    With List1
    .StartAt = ListNumberBefore + 1
    End With

    However, I get the following error:

    Compile error. Object required.

    Please advise what I am doing wrong or if there is a better way.

    Thanks!!
    Troy

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Resetting a number in the middle of a list (Word 2003 VBA)

    Same problem. ListLevels(...) returns a ListLevel object, not a number. If you want to get at the list level number, you can use

    List1 = Selection.Range.ListFormat.ListLevelNumber

  5. #5
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Resetting a number in the middle of a list (Word 2003 VBA)

    Sorry, I guess I am not being clear. Nothing new for me.

    I am not trying to "return" anything. I am trying restart number at, for example, "3" for a list item that is currently set to start at "1".

    How do I do that.

    Thanks!!
    Troy

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Resetting a number in the middle of a list (Word 2003 VBA)

    Sorry, I can't help here. Hopefully someone else will have a suggestion (I'll be learning something too).

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

    Re: Resetting a number in the middle of a list (Word 2003 VBA)

    Could you simplify the code to...
    <code>
    Selection.Range.ListFormat.ListTemplate.Listlevels (Selection.Range.ListFormat.ListLevelNumber).Start At = ListNumberBefore + 1
    </code>

    StuartR

  8. #8
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Resetting a number in the middle of a list (Word 2003 VBA)

    This code works in that it causes no error. The problem is that it causes all the lists in the entire document to start at whatever value is set here. In other words, if I want to change the startat value from "a" to "c", all lists at that level in the entire document now start at "c".

    Any other ideas?

    Thanks!!
    Troy

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

    Re: Resetting a number in the middle of a list (Word 2003 VBA)

    In that case I think this is going to get very complex, as I think you will need to create a new ListTemplate with a new name for each different starting number. Unless someone else has a brighter idea.

    Do all your ListTemplates already have names that you have defined and could use in a Macro? This might make it easier.

    StuartR

  10. #10
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Resetting a number in the middle of a list (Word 2003 VBA)

    I have a single list template named "myListItems". It is a multilevel list where the first two levels are dummy list items that are tied to specific styles that help it restart.

    Thus my problem. When the styles appear, say in a table, and the list continues, it starts over at 1. I can manually change it to start at whatever I want, but I'd prefer to do it in a macro.

    Any ideas would be appreciated!!

    Thanks!!
    Troy

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

    Re: Resetting a number in the middle of a list (Word 2003 VBA)

    Please check something for me.

    When you manually restart the list at a different number, if you then go back to the Bullets and Numbering dialog box is it definitely still using the same ListTemplate as all the other similar lists?

    regards,

    StuartR

  12. #12
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Resetting a number in the middle of a list (Word 2003 VBA)

    Stuart,
    I used the following:

    MsgBox Selection.Range.ListFormat.ListTemplate.Name

    on steps that had not been reset and on a step I manually reset. They both came back with the same name.

    Troy

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

    Re: Resetting a number in the middle of a list (Word 2003 VBA)

    I really have no more ideas on this one, hopefully someone more knowledgeable will turn up soon...

    StuartR

  14. #14
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Resetting a number in the middle of a list (Wo

    I don't think you can use the same listtemplate to reset lists to restart at more than one number. I also can't see a reason to actually do this either.

    If you really need to set items in the list to specific numbers then I would expect that you have to either:
    1. Create another listtemplate for that specific occurrance
    2. Use Seq fields instead of lists to do your numbering. These can be reset to any number quite easily.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  15. #15
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Resetting a number in the middle of a list (Wo

    Andrew,
    Thanks for your kind attention to my problem!!

    As far as why I need to reset numbering in the middle of a list, I have a single list template named "myListItems". It is a multilevel list where the first two levels are "dummy" list items that are tied to specific styles that help numbering to restart at other levels.

    Thus my problem. When the styles appear, say in an if/then table in the middle of a list, and the list continues, it starts over at 1. I have to put some of those dummy styles in the table so I can restart substeps in the second if/then row of the table. I can manually change it to start at whatever I want, but I'd prefer to do it in a macro.

    Hey, I just had a thought. If I create a second list template and use the macro to apply that to the list items in these tables, will that list template interfere with numbering before and after the table if the numbering before and after the table use the other list template? If not, that may solve my problem. I could create a new "dummy" style to use in the if/then tables to reset numbering for the second and following if/then scenarios, and that dummy style should not restart items in my first list template since it will not appear in that template.

    What do you think, or did I lose you?

    Troy

Page 1 of 2 12 LastLast

Posting Permissions

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