locked
MS Word - Get ListNumber

    Question

  • Hi guys,

    I am using interop to read an MS Word document.

    The text of the document is numbered, like

    1 Title

    1.1 sub title A

    1.1.1 Sub title B

    How can I get the number of each paragraph?

    I tried with:

    // Get paragraph style.  
    Style paragraphStyle = (Word.Style)oRange.get_Style();  
    int number = paragraphStyle.ListLevelNumber;  
     

    but I don't get what I need.

    Thanks in advance,

    Aldo.


    Everything is possible, impossible just takes longer
    Thursday, January 29, 2009 2:09 PM

Answers

  • Hello,

    Please try to use Microsoft.Office.Word.Interop.Range.ListFormat.ListString.   This property will give us the string of list number, such as “1.” for “1. Title”.

    Range oRange = oDoc1.Paragraphs.First.Range;

    MessageBox.Show(oRange.ListFormat.ListString);

     

    Best Regards,
    Lingzhi


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. http://forums.msdn.microsoft.com/en-US/csharpide/thread/8e9ed0d7-11ff-402a-8489-9b5f05eeb706 http://forums.msdn.microsoft.com/en-US/vssetup/thread/60424309-bd78-4ca2-b618-03c4a16123b6
    • Marked as answer by ajliaks Tuesday, February 03, 2009 8:21 AM
    Tuesday, February 03, 2009 7:36 AM
    Moderator

All replies

  • Hello,

    Please try to use Microsoft.Office.Word.Interop.Range.ListFormat.ListString.   This property will give us the string of list number, such as “1.” for “1. Title”.

    Range oRange = oDoc1.Paragraphs.First.Range;

    MessageBox.Show(oRange.ListFormat.ListString);

     

    Best Regards,
    Lingzhi


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. http://forums.msdn.microsoft.com/en-US/csharpide/thread/8e9ed0d7-11ff-402a-8489-9b5f05eeb706 http://forums.msdn.microsoft.com/en-US/vssetup/thread/60424309-bd78-4ca2-b618-03c4a16123b6
    • Marked as answer by ajliaks Tuesday, February 03, 2009 8:21 AM
    Tuesday, February 03, 2009 7:36 AM
    Moderator
  • Thanks!
    Everything is possible, impossible just takes longer
    Tuesday, February 03, 2009 8:21 AM