Modify text of Footer of a docx (MS Word 2013) file

328 Views Asked by At

I am using DocX library to modify a word file. I replaced a text in this document as follow:

using (DocX document = DocX.Load(@"E:\Test.docx"))
{
    document.ReplaceText("text", "replaced");
    document.Save();
}

But, texts in Footer of the file are not replaced. The question is How can I modify texts in the Footer of the docx file?

1

There are 1 best solutions below

0
OmG On BEST ANSWER

You should replace texts of footer using Footer property for both even and odd likes the following:

// ...
document.Footers.odd?.ReplaceText("text","replaced");
document.Footers.even?.ReplaceText("text","replaced");

document.Save();