Janee Janee - 1 year ago 80
C# Question

Determine if the paragraph is a standard text or a heading

Is there a way to determine if the paragraph is a standard text or a heading?

Without using any third party components like


Please note the following Code: This works only if the Word Style "Heading 1" is not renamed.

object thisTempStyle = p.get_Style();
Style thisparagraphStyle = thisTempStyle as Style;
string actualStyle = thisparagraphStyle.NameLocal;

if (actualStyle == "Heading 1")

So, i'd like to get the Headings without knowing their names.

Thank you

Answer Source

You can also check the outline level of the paragraph (https://msdn.microsoft.com/en-us/library/office/ff839401.aspx).

  case WdOutlineLevel.wdOutlineLevel1:
    // Heading 1
  case WdOutlineLevel.wdOutlineLevelBodyText:
    // Body Paragraph
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download