ReplaceAll does not replace all when inserting paragraphs

Questions and answers on how to use DOCXReadWrite
Post Reply
Vinzenz
Posts: 4
Joined: Mon Feb 20, 2023 1:24 pm

ReplaceAll does not replace all when inserting paragraphs

Post by Vinzenz »

Hi,

I use the ReplaceAll command to replace placeholders in my document, which usually works fine. However, if I insert a paragraph to the document, all placeholders that are further down in the document, than the new paragraph do not get replaced anymore. Is there a way to circumvent that?

Here is the example:

Code: Select all

    DOCX.Editor.FindReplace.BeginReplaceUI(Placeholder,NewText);
    DOCX.Editor.FindReplace.ReplaceAll;
    DOCX.Editor.FindReplace.EndFind;
That works fine, until I add

Code: Select all

DOCX.Editor.Paras.Insert(10);
to the code. Now everything past Paragraph 10 is not getting replaced anymore.

How can I add paragraphs while also replacing all placeholders?
Post Reply