// remove characters that need not be printed from end of
selection.
// failing to do so screws up the repeat loop below.
S := richedit1.SelText;
while (fmtRange.chrg.cpMax > 0) and
(S[fmtRange.chrg.cpMax] <= ' ') do Dec(fmtRange.chrg.cpMax);