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

Free Support Forum - aspose.com

Range.Replace does not replace text

var doc = new Aspose.Words.Document(path);
int i = doc.Range.Replace("[Customers].[Name]", "Aspose", true, true);

The above code does not replace the text. When I inspect the document xml, the text [Customers].[Name] is split over more elements. Is that the problem?

Hi Henrik,

Thanks for your inquiry. Could you please attach your input Word document you’re getting problem with here for testing? I will investigate the issue on my side and provide you more information.

Best Regards,

I Have Attached the document.
Thanks
Henrik

The search text in the attached document i slightly different: [Customer].[Name], but same result.
Thanks

Hi
Henrik,

Thanks for your inquiry. Please use the following correction that worked for me:

Document doc = new Document(@"c:\temp\Invoice.docx");
int i = doc.Range.Replace("[Customer].[Name]",

“Aspose”, true,
false);

Best Regards,

Works for me too. Thanks :slight_smile: