Aspose.word do a replace operation in document body only (do not replace in header/footer)

Hello,

I want to do a replace operation on all the pages of my document but not in its header/footer.
However when i call MyDocument.Range.Replace, the method is also applied in the header/footer.

How can i avoid that ?

Sincerely.

@aaronArchest You can achieve this by performing replace operation only in the document’s body:

Document doc = new Document("C:\\Temp\\in.docx");

foreach (Section s in doc.Sections)
    s.Body.Range.Replace("text to replace", "replacement");

doc.Save("C:\\Temp\\out.docx");
1 Like