Sometimes you want to process all paragraphs in a document, and filter based on the style name. However, sometimes it isn’t good enough to just filter on the style name, because if another style inherits from the style of interest, you want to include it in your processing. A common example is that you want to process all paragraphs that are styled as “Heading1”, and all paragraphs that have a style that is based on “Heading1”.

Blog TOCThe following example shows how to iterate through a document, and test whether each paragraph is styled as “Heading1” or one derived from it. The StyleChainReverseOrder method is an iterator that returns a collection of styles in the style chain; however, the styles in the returned collection are in most-derived to least-derived order. The StyleChain method returns the collection from least-derived to most-derived, which most often is the order that you want to process them. In this case, it doesn't really matter, but in others it does, so I included both methods in this post. The interesting method in this post is the IsStyleBasedOnStyle method. You can pass two style names to the IsStyleBasedOnStyle method, and it returns true if the style in the styleId argument is based on the style in the basedOnStyleId style. This example uses the strongly-typed OM, but it's pretty easy to convert to use LINQ to XML if that is what you are using.

The altChunk importing functionality of Word supports the following formats for the imported content:
This blog is inactive. New blog: EricWhite.com/blog Blog TOC
AlternativeFormatImportPartType enum
Content Type
...

I regularly use functional programming and LINQ in two contexts – when writing code that is part of an example or tool that will potentially execute millions of times, and when writing ad-hoc queries. These days, I use C# and LINQ as my ‘scripting...

This is one in a series of posts on transforming Open XML WordprocessingML to XHtml. You can find the complete list of posts here .
Recently I went through the process of handling a variety of details in the XHtml converter – generating XHtml...

Writing encoded (utf-8, utf-16, etc.) documents using LINQ to XML is pretty straight-forward, but there is one interesting dynamic of the semantics. When serializing to a file on disk, then you can set the encoding in the XML declaration, and the resulting...

Some time ago, I blogged about an approach for converting an XElement object to an XmlNode object , and vice versa. This is useful when you want to use a programming interface that takes and returns objects of type XmlNode, but you want to use the expressiveness...

Open XML developers create new documents in a variety of ways – either through transforming from an existing document to a new one, or by programmatically altering an existing document and saving it back to disk. It is valuable to use the Open XML...

Data and content extraction is one of the scenarios where content controls are very useful. Data extraction is when you are extracting specific numbers or string values from a document. Content extraction is when you are extracting formatted WordprocessingML...

This is one in a series of posts on transforming Open XML WordprocessingML to XHtml. You can find the complete list of posts here .
When building a document processing system based on Open XML WordprocessingML, one approach to making your software...