none
how to set list level for word 2002 xp RRS feed

  • Question

  • can some1 plz help me out

    hpe in z rite forum

    i need to set level of a list in word 2002 c#

    4 word 2010 we can do it this way
    app.Selection.Range.SetListLevel(1);

    but cant use it in 2002

    does any1 knw how to do it in word 2002 plz???

    plz help, its urgent

    thks

    Monday, November 29, 2010 12:02 PM

Answers

  • You need to use the list level number with the percentage sign. For example, here's some code that formats the first three levels of a list template:

      Set lt = rng.Document.ListTemplates.Add(True, "TestLT")
      With lt.ListLevels(1)
        .NumberStyle = wdListNumberStyleArabic
        .NumberFormat = "%1 "
      End With
      With lt.ListLevels(2)
        .NumberStyle = wdListNumberStyleArabic
        .NumberFormat = "%2 "
      End With
      With lt.ListLevels(3)
        .NumberStyle = wdListNumberStyleArabic
        .NumberFormat = "%3 "
      End With
    
    

     


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Bessie Zhao Tuesday, December 7, 2010 9:21 AM
    Wednesday, December 1, 2010 11:44 AM
    Moderator

All replies

  • Hi Star Mush

    The SetListLevel method was introduced in Word 2007 and is not available in earlier versions of Word.

    I believe what you're looking for would be:

    app.Selection.Range.ListFormat.ListLevelNumber = 1;


    Cindy Meister, VSTO/Word MVP
    Monday, November 29, 2010 4:06 PM
    Moderator
  • Hi, thks 4 replying Cindy

    the ListLevelNumber will work only 4 multilist, isnt it?

    what i've used work fine for normal paragraph style
    app.Selection.Range.ListFormat.ListIndent();

    but when paragraph style is changed to TEXT which is a style indenting the paragraph by 1.65 i think

    then the bullets or numbers doesnt work properly if i do a LisIndent :(

    i mean the indentation of the bullets an numbers

     

    any suggestions of what i can do???

    plz help

    thks

     

     

    Tuesday, November 30, 2010 5:47 AM
  • My dear Cindy, i need to thk u loads for setting me back on z rite track

    i was using single level list before

    u said to use ListLevelNumber, n i did come across it b4 n knew we had to use multilist with zat 1

    so i change my list to multi list

    n earlier i didnt really knw how to use the stuff, now zat i've gone through it again i realised my mistake all thks to u :)

     

    for normal paragraph style i used this:


                    ListTemplate lTemp = app.ActiveDocument.ListTemplates.Add(Type.Missing);

                    //multilist
                    lTemp.Convert(1);

                  lTemp.ListLevels[levelNum].NumberFormat = "•";    //(My mistake was here i alwayz put .ListLevels[1] ) :$

                  app.Selection.Range.ListFormat.ApplyListTemplate(lTemp, false);

                 app.Selection.Range.ListFormat.ListLevelNumber = levelNum;

    levelNum for the 3 indents i need i used 2,3 ,4

     

    n for paragraph style being "Text" hving indent 1.65

    levelNum for the indents i used 5, 6, 7

     

    Only a small question: why is it zat .ListLevelNumber = 1 and .ListLevelNumber = 2 hve same indent???

    zats why  instead of ListLevelNumber being 1,2 ,3 i used 2, 3 ,4

     

    wow been on zat 4 quite a long time, finally solved z prob

    thks again Cindy :)

    • Marked as answer by StarMush Tuesday, November 30, 2010 7:33 AM
    • Unmarked as answer by StarMush Wednesday, December 1, 2010 4:17 AM
    Tuesday, November 30, 2010 7:24 AM
  • <<Only a small question: why is it zat .ListLevelNumber = 1 and .ListLevelNumber = 2 hve same indent???

    zats why  instead of ListLevelNumber being 1,2 ,3 i used 2, 3 ,4>>

    Probably because that's how the ListTemplate formatting has been defined. Each level of numbering can be formatted separately for such things as indent of the number, indent of the text, what "symbol" is used for the number, if the level is linked to a style, how re-numbering should work, etc. Basically, everything you'd find in the Format/Bullets and Numbering dialog box.

    Programmatically, these things are properties of the ListTemplate.ListLevel object and you can see them in the object model Help.


    Cindy Meister, VSTO/Word MVP
    Tuesday, November 30, 2010 8:41 AM
    Moderator
  • i hve a small bug

    when i use the one below wiz the levelNum 2,3,4,5,6,7, it bugs n does'nt increment

    keep having 1 1 1  :(

    lTemp.ListLevels[levelNum].NumberFormat = "%1";

    found zat the NumberFormat = "%1" increments only when ListLevelNumber = 1

     

    when i used NUmberStyle instead like below

     
                 lTemp.ListLevels[levelNum].NumberStyle = WdListNumberStyle.wdListNumberStyleArabic;
                  app.Selection.Range.ListFormat.ApplyListTemplate(lTemp, false);

                 app.Selection.Range.ListFormat.ListLevelNumber = levelNum;

    levelNum represents z levels i used meaning 2,3,4  5,6,7

    for 2,3,5,6, i get zis
    1)

    2)

    3)

    n for 4, 7 i get zis

    (1)

    (2)

    (3)

    n wat i need is

    1

    2

    3

     

    for the bullets it work fine there's no incrementing in it

    Can sme1 plz help me wiz it??? :(

    thks in advance

    Tuesday, November 30, 2010 8:47 AM
  • You need to use the list level number with the percentage sign. For example, here's some code that formats the first three levels of a list template:

      Set lt = rng.Document.ListTemplates.Add(True, "TestLT")
      With lt.ListLevels(1)
        .NumberStyle = wdListNumberStyleArabic
        .NumberFormat = "%1 "
      End With
      With lt.ListLevels(2)
        .NumberStyle = wdListNumberStyleArabic
        .NumberFormat = "%2 "
      End With
      With lt.ListLevels(3)
        .NumberStyle = wdListNumberStyleArabic
        .NumberFormat = "%3 "
      End With
    
    

     


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Bessie Zhao Tuesday, December 7, 2010 9:21 AM
    Wednesday, December 1, 2010 11:44 AM
    Moderator