Free Support Forum - aspose.com

Seaching Entire Word Doc having similar sytles

Hi,

Am I able to use Aspose Word to search a Word document for paragraphs having similar styles?

Thanks and Regards,

John Tan

Hi John,

Thank you for your interest in Aspose.Word.

Yes, you can search a Word document for paragraphs having similar styles with Aspose.Word.

I will prepare a sample shortly and post it in this topic.

This sample code looks for a paragraph having 'Heading 1' style.

Document doc = new Document(Application.StartupPath + "\\doc1.doc");

foreach(Paragraph p in doc.GetChildNodes(NodeType.Paragraph, true)) {

if(p.ParagraphFormat.StyleName == "Heading 1") {

MessageBox.Show("Pargraph :\r\n\r\n" + p.GetText() + "\r\n" + "has style 'Heading 1'");

}

}