c# - Programmatically count number of characters/words/paragraphs with a specific style in a DOCX document -


i need programmatically count characters and/or words and/or paragraphs have been applied specific known style in docx document.

i need know 1) if possible , 2) hints can start going solve problem.

i familiar dom navigation, xpath/xquery, , can use .net, php or java or other tool long can solve problem.

microsoft.office.interop.word.application word = new microsoft.office.interop.word.application();         microsoft.office.interop.word.document doc = new microsoft.office.interop.word.document();          try         {             object filename = @"c:\tt\change.docx";             doc = word.documents.open(ref filename,                 ref missing, ref missing, ref missing, ref missing,                 ref missing, ref missing, ref missing, ref missing,                 ref missing, ref missing, ref missing, ref missing,                 ref missing, ref missing, ref missing);              doc.activate();              int count = doc.characters.count ;             int words = doc.words.count; ;             int paragraphs = doc.paragraphs.count;              doc.save();              doc.close(ref missing, ref missing, ref missing);             word.application.quit(ref missing, ref missing, ref missing);         }         catch (exception ex)         {             doc.close(ref missing, ref missing, ref missing);             word.application.quit(ref missing, ref missing, ref missing);         }   

Comments