I am using the following code to find an expression & replace it with a string.
I am using the following code, and there are 2 things happening
- either I receive the error "Object reference not set to an instance of an object. "
- or it goes through the ReplaceHandler numerous times, when the expression being replaced is only in there once.
Regex regex = new Regex(@"[PlaceHolder]");
WorkDocClone.Range.Replace(regex, new ReplaceEvaluator(ReplaceHandler), false);
private ReplaceAction ReplaceHandler(object sender, ReplaceEvaluatorArgs e)
{
DocumentBuilder DB = new DocumentBuilder((Document) e.MatchNode.Document);
DB.MoveTo(e.MatchNode);
DB.StartBookmark("Addressee");
DB.EndBookmark("Addressee");
DB.MoveToBookmark("Addressee", true, true);
DB.Font.ClearFormatting();
DB.Writeln(_ESignAddressees);
return ReplaceAction.Replace;
}