Click here to Skip to main content
15,885,906 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to find and replace string in Footer of Word document in C#?
Posted

Thank you so much. but the below code solved my problem

C#
object replaceAll = MSWord.WdReplace.wdReplaceAll;

foreach (Microsoft.Office.Interop.Word.Section section in oDoc.Sections)
{
      Microsoft.Office.Interop.Word.Range footerRange = section.Footers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
      footerRange.Find.Text = "Some Text";
      footerRange.Find.Replacement.Text = "Replace Text";
      footerRange.Find.Execute(ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref replaceAll, ref missing, ref missing, ref missing, ref missing);
                    }
 
Share this answer
 
v2
Comments
Beginner Luck 5-Feb-16 22:14pm    
THank i also learn some thing

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900