Created
May 22, 2024 14:05
-
-
Save openize-words-gists/a0f6f0413e309a5dbb27d7e366f6ffa5 to your computer and use it in GitHub Desktop.
C# Modify Multiple Multilevel List Paragraphs in Word Documents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Prerequisite: Install <a href="https://www.nuget.org/packages/Openize.Words">Openize.Words</a>. | |
// Load the Word Document | |
var doc = new Openize.Words.Document($"MultilevelLists.docx"); | |
// Initialize the body with the document | |
var body = new Openize.Words.Body(doc); | |
foreach (var paragraph in body.Paragraphs) | |
{ | |
if (paragraph.Style == "ListParagraph") | |
{ | |
paragraph.IsNumbered = true; | |
paragraph.AddRun(new Openize.Words.IElements.Run | |
{ Text = " (numbering type changed to numeric)", Italic = true }); | |
doc.Update(paragraph); | |
} | |
} | |
// Save the modified Word Document | |
doc.Save($"ModifiedMultilevelLists.docx"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment