none
How to finish numbered list? RRS feed

  • Question

  • Sometimes document contain numbered list and I want to insert some text after numbered list.

    Now I use method Range.InsertAfter for adding some text, its works fine, but in case when text is added at the end of numbered list Word is add my text as new list item and set some number before my text (list is not finished yet). 

    So, I should finish numbered list, but I don't know how...

    Thursday, October 20, 2011 9:57 AM

Answers

  • Well, you'd have to show me the code but...

    You know you have to "collapse" the Range to the point after the numbering before you apply the method? Range.InsertAfter includes what you insert into the Range, so the method affect the entire range.

    You first need to do something like:

    rng.Collapse(wdCollapseEnd)


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Liliane Teng Thursday, October 27, 2011 9:23 AM
    Thursday, October 20, 2011 3:06 PM
    Moderator
  • As Cindy suggested, first collapsing to the end of the range would remove numbering from the last paragraph which is part of the range.
     
    Assuming that you use a range object stored in a variable and add content to that range, you can specify exactly from which paragraph (of the range) numbering should be removed.

    Stefan Blom, Microsoft Word MVP
    Monday, October 24, 2011 5:31 PM

All replies

  • Hi Digor

    See if this helps

    .Range.ListFormat.RemoveNumbers()

    If you're still having problems, it would be helpful to know in what manner you're using the Numbering. Most especially, whether you link the numbering to a specific paragraph style or not.


    Cindy Meister, VSTO/Word MVP
    Thursday, October 20, 2011 10:02 AM
    Moderator
  • Cindy,

    Thank you, but Range.ListFormat.RemoveNumbers() just remove all numbers in numbered list, but I want just add text after numbered list without numbering

    For example we have list in Word document:

     

    1) first sentence
    2) second sentence
    3) sentence
    
    

     


    I would like just add string "some text" at the end of numbered list, like:

    1) first sentence
    2) second sentence
    3) sentence
    some text
    


    After adding string "some text" to range with above list (I've use method Range.InserAfter) I've get numbered last string:

    1) first sentence
    2) second sentence
    3) sentence
    4) some text
    


    After Invoking RemoveNumbers I've get non-numbered list:

    first sentence
    second sentence
    sentence
    some text
    
    So, RemoveNumbers  just remove all numbers in list...

    Thursday, October 20, 2011 11:58 AM
  • Well, you'd have to show me the code but...

    You know you have to "collapse" the Range to the point after the numbering before you apply the method? Range.InsertAfter includes what you insert into the Range, so the method affect the entire range.

    You first need to do something like:

    rng.Collapse(wdCollapseEnd)


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Liliane Teng Thursday, October 27, 2011 9:23 AM
    Thursday, October 20, 2011 3:06 PM
    Moderator
  • Cindi, thank you

    We should use Range.ListFormat.RemoveNumbers method, but only for range with text where number removing is needed. 

    I've set range.Start equal to position when "some text" starts and after invoking RemoveNumbers numbers was removed


    Monday, October 24, 2011 3:52 PM
  • As Cindy suggested, first collapsing to the end of the range would remove numbering from the last paragraph which is part of the range.
     
    Assuming that you use a range object stored in a variable and add content to that range, you can specify exactly from which paragraph (of the range) numbering should be removed.

    Stefan Blom, Microsoft Word MVP
    Monday, October 24, 2011 5:31 PM