Page 1 of 1

Reset FindReplace

Posted: Mon Feb 20, 2023 1:36 pm
by Vinzenz
Hello,

I am using the FindReplace method to replace text in my document. When I use ReplaceAll everything works finde, but now I would like to only replace the first instance of a text, so I tried using FindNext and then Replace. My code looks like this:

Code: Select all

    DOCX.Editor.FindReplace.BeginReplaceUI(Placeholder,NewText);
    If DOCX.Editor.FindReplace.FindNext then
      DOCX.Editor.FindReplace.Replace;
    DOCX.Editor.FindReplace.EndFind;
This works fine once. But if I recall it later with another placeholder and text, it keeps on searching from where it stopped and not from the beginning of the document.
How can I "reset" the search, so that it always starts from the beginning?

I tried the "Restart()" procedure, but didn't find a way to call for the first position of the document. I am unsure if this is the right approach anyway.

Any help would be much appreciated.