I have an issue with the Range.Replace method. When I replace a text that is horizontally aligned to the center and replace it with a text that has a newline (&p), only the last line is center aligned and the rest are left aligned. If I use Environment.NewLine instead of &p all lines are aligned correctly to the center but the line-spacing is wrong.
After some debugging I discovered that this behaviour can be changed with the FindReplaceOptions.ApplyParagraphFormat.Alignment option. By giving it another value all lines but the bottom one are aligned like the value was set. The problem for me is that I want to keep the alignment of the text and that I’m replacing multiple times and I don’t know the alignment of the texts I replace.
Is there any way to tell the ReplaceOptions to not apply any format and keep that of the original text?
In the attached example you see the the outcome of a multiline replacement using either &p or Environment.NewLine.
WordReplace.zip (4.9 MB)
Best regards
Wolfgang