none
Add a bullet correctly below the text in the previous line. RRS feed

  • Question

  • Hi All,

    I know how to add bullets in a word doc, but I dont know how to set the range.listformat.leftindent property to match this particular reuirement i.e

    1.1.1.   some text 

               (add a bullet below s in some)

    normal text

    (add a bullet below n) 

    i.e check where start of the text is , in the previous line add a bullet right below this text dynamically

               


    Friday, January 23, 2015 6:41 AM

Answers

  • Ideally, you would define a paragraph Style for each potential bullet indent (e.g. Bullet1, Bullet2, Bullet3), then simply apply that Style according to whatever level of indenting you need. After all, you may not always want:

    •     text 1
          •     text 2
                •     text 3

    Sometimes you may need:

         •     text 1
         •     text 2
         •     text 3

    or even:

    •     text 1
         •     text 2
    •     text 3

    Trying to manage all this via programmatically in-denting/out-denting the text is much more involved than simply applying a Style to the paragraph. Using Styles also simplifies the choice of bullet character for each level of indent.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    Tuesday, January 27, 2015 6:28 AM

All replies

  • Hi Apoorva,

    I'm not quite sure what your uiquirement is, seems that you want to insert a sub-level bullet below the previous paragraph. You can use this method to create a sub-level bullet in the word document.

    Range.ListFormat.ListIndent

    For example:

    Application app = new Application();
                app.Visible = true;
                Document doc = app.Documents.Add();
                Paragraph para= doc.Content.Paragraphs.Add();
                Range rng = para.Range;
    
                para = doc.Content.Paragraphs.Add();
                para.Range.ListFormat.ApplyBulletDefault();
                para.Range.InsertBefore("test1");
    
                para = doc.Content.Paragraphs.Add();
                para.Range.ListFormat.ApplyBulletDefault();
                //para.Range.ListFormat.ListOutdent();
                para.Range.ListFormat.ListIndent();
                para.Range.InsertBefore("test2");


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, January 26, 2015 3:35 AM
    Moderator
  • Thanks a lot Caillen , the requirement says that 

    If I have a line in a word document such as the one below, I want my bullets to appear like this :

    1.1.1.  this is a line

                

    i.e my bullets should line up with the 't' in 'this is a line' .

    Suppose my line is this,my bullets should appear  like this .

    This is a normal para

    i.e the level 1 bullet should align with the 'T' in 'This is a paragraph' , in other words , auto left indent based on the previous line


    Tuesday, January 27, 2015 5:00 AM
  • Ideally, you would define a paragraph Style for each potential bullet indent (e.g. Bullet1, Bullet2, Bullet3), then simply apply that Style according to whatever level of indenting you need. After all, you may not always want:

    •     text 1
          •     text 2
                •     text 3

    Sometimes you may need:

         •     text 1
         •     text 2
         •     text 3

    or even:

    •     text 1
         •     text 2
    •     text 3

    Trying to manage all this via programmatically in-denting/out-denting the text is much more involved than simply applying a Style to the paragraph. Using Styles also simplifies the choice of bullet character for each level of indent.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    Tuesday, January 27, 2015 6:28 AM