chetan Allipur

chetan Allipur

  • NA
  • 541
  • 168.8k

How to Find and Replace the word styles in c#

Jul 4 2018 8:41 AM
Range rng = doc1.Content;
rng.Find.ClearFormatting();
rng.Find.Replacement.ClearFormatting();
rng.Find.set_Style(doc1.Styles["Body Text"]);
rng.Find.Forward = true;
rng.Find.Wrap = WdFindWrap.wdFindContinue;
if (rng.Find.Execute())
{
rng.set_Style(doc1.Styles["Heading 1"]);
}
If I have styles in multiple places in document.It is not working.Only first occurrence will work other same styles will not change.
Can anybody tell me?

Answers (2)