We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Range.replace issue

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.MoveToBookmark("Addressee", true, true);



return ReplaceAction.Replace;



<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. I think in this case you should use the same technique as demonstrated in the following thread:

If you need more assistance, I will be glad to help you.

Best regards,