LibreOffice Writer Macro to run on Selected Text Only

This isn’t quite correct. An inserted replacement always gets the attributes from the next position left of its start. If the finding getting replaced is not inside of an uniformly formatted text range there will be a change.
See attachment-in-return:
find_repl_in_selection_ReExcept.odt (16.6 KB)
To avoid his, you should firszt insert the replacement behind the finding, and annullated the found part subsequently. If the search string isn’t formatted uniformly at all, there isn’t an unambiguos requirement concerning the attributes to use for the replacement anyway.

I forgot this behavior :-).

Here is the fix, of course it supposes only one formatting for wanted items.
find_repl_in_selection_ReExcept-3.odt (17.0 kB)

I tried to make the multiformat F&R in past, but I still didn’t finish it.

1 Like

Thanks a lot

My PC hangs if I put hundreds of items in the array.

@AniruddhaMohod I think it is excpetable behavior of your computer for hundreds of items :-(.