Method DeleteStyle
DeleteStyle(WordDocument, DocumentPosition, string)
Deletes a style, as the Styles pane's Delete does (WQ-0109). Paragraphs of the style take the default
paragraph style, and runs and tables of it lose their style; direct formatting stays. A style based on it is
based on the default style of its type instead and takes the deleted chain's formatting under its own, so it
looks as it did. A w:next naming it names the default paragraph style. A paragraph style and the
character style linked to it are deleted together; when the other one is a built-in style it stays, without
the link.
public static DocumentEdit DeleteStyle(this WordDocument document, DocumentPosition at, string styleId)
Parameters
documentWordDocumentThe document.
atDocumentPositionstyleIdstringThe style's id.
Returns
- DocumentEdit
The edit; undoing it puts the styles back where they were in the definitions, and the text's references to them.
Exceptions
- ArgumentNullException
documentorstyleIdis null.- ArgumentException
The position is not in the document, or no style has the id.
- InvalidOperationException
The style is a default or built-in style, or a numbering style (CanDeleteStyle(WordDocument, string) is false).