I'm a learner in using Microsoft.Office.Interop.Word
. Consider I have a word document with headings in style 'Header1' and some sentences of style 'normal' comes under it. Now I need to find those lines that comes under a paragraph of style 'Header 1'. This is what I have been coded so for:
foreach (Microsoft.Office.Interop.Word.Paragraph paragraph in doc.Paragraphs)
{
Microsoft.Office.Interop.Word.Style style = paragraph.get_Style() as Microsoft.Office.Interop.Word.Style;
string styleName = style.NameLocal;
string text = paragraph.Range.Text;
if (styleName == "Heading 1")
{
MessageBox.Show("Sent lines :" + text.ToString()); //this will show all headings
}
}
How do I display the all lines that comes under those headings?
I think you want something like this, assuming I understand your question:
//get the 'next' paragraph but only if it exists
if (paragraph.Next() != null)
{
MessageBox.Show("Next paragraph:" + paragraph.Next().Range.Text.ToString());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With