Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I know if a Word list is a bullet list or a numeric list?

I am reading a word document (converting it to HTML) and want to know what type each paragraph is (at least that's the way I think I want to do it like).

My code looks like this

Application application = new Application();
var doc = application.Documents.Open("D:\\myDoc.docx");

for (int i = 0; i < doc.Paragraphs.Count; i++)
{
     Console.WriteLine($"{doc.Paragraphs[i + 1].Range.ParagraphStyle.NameLocal}");
}

This outputs Header 1, Normal and List Paragraph for instance. So my question. I can't see if List Paragraph is a bullet list or a numeric list. Question, How can I know what type the list is of?

like image 714
Andreas Avatar asked Jan 26 '26 18:01

Andreas


1 Answers

Use Range.ListFormat.ListType which can have the following values:

// Summary:
//     Specifies a type of list.
public enum WdListType
{
    // Summary:
    //     List with no bullets, numbering, or outlining.
    wdListNoNumbering = 0,
    //
    // Summary:
    //     ListNum fields that can be used in the body of a paragraph.
    wdListListNumOnly = 1,
    //
    // Summary:
    //     Bulleted list.
    wdListBullet = 2,
    //
    // Summary:
    //     Simple numeric list.
    wdListSimpleNumbering = 3,
    //
    // Summary:
    //     Outlined list.
    wdListOutlineNumbering = 4,
    //
    // Summary:
    //     Mixed numeric list.
    wdListMixedNumbering = 5,
    //
    // Summary:
    //     Picture bulleted list.
    wdListPictureBullet = 6,
}
like image 99
NineBerry Avatar answered Jan 28 '26 08:01

NineBerry



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!