Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save openize-words-gists/08e214d1abbf7603657d9b42e3ed9822 to your computer and use it in GitHub Desktop.
Save openize-words-gists/08e214d1abbf7603657d9b42e3ed9822 to your computer and use it in GitHub Desktop.
C# Modify Multiple Frame Paragraphs in Word Documents
// Prerequisite: Install <a href="https://www.nuget.org/packages/Openize.Words">Openize.Words</a>.
// Load the Word Document
var doc = new Openize.Words.Document($"WordParagraphsFrame.docx");
var body = new Openize.Words.Body(doc);
foreach (var paragraph in body.Paragraphs)
{
if (paragraph.ParagraphBorder.Size > 0)
{
paragraph.ParagraphBorder.Width = Openize.Words.IElements.BorderWidth.Single;
paragraph.ParagraphBorder.Color = Openize.Words.IElements.Colors.Black;
foreach (var run in paragraph.Runs)
{
// Modified paragraph text
run.Text = "Paragraph border modified to single width with black color";
}
System.Console.WriteLine("Frames/Borders changed to single width with black color");
}
// Update the paragraph in the document
doc.Update(paragraph);
}
// Save the modified Word Document
doc.Save($"ModifiedParagraphsFrame.docx");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment