Find and replace not working

Hi
Find and replace is not working in my docx. Can you please check?

Thanks
Gaurav

test.docx (22.7 KB)

I tried replacing the text SunBurn.

@gkumar16 I have checked with the following simple code and text is replaced properlu:

Document doc = new Document("C:\\Temp\\in.docx");
doc.getRange().replace("SunBurn", "REPLACED");
doc.save("C:\\Temp\\out.docx");

out.docx (13.9 KB)

It’s not working when I am using the following find and replace option.

FindReplaceOptions findReplaceOptions = new FindReplaceOptions();
findReplaceOptions.setFindWholeWordsOnly(true);

document.getRange().replace("SunBurn.", "REPLACED", findReplaceOptions);

@gkumar16 This is expected behavior. If you search “SunBurn” with Find whole words only in MS Word, it also does not match anything:

@alexey.noskov
Thank you for clarifying.

1 Like