- Offizieller Beitrag
ZitatI would like to append long string variables to a WPTools document but with some words and phrases in bold characters. What is the easiest and fastest way to do this?
You can either use RTF code:
WPRichText1.SelectionAsString :=
'{\rtf{This is a \b1 Word\b0 in bold font}}';
Note that after the \b0 and \b1 commands there is one space which is always ignored.
or use this code:
WPRichText1.BeginUpdate;
WPRichText1.InputString ('This is a ');
WPRichText1.CurrAttr.AddStyle([afsBold]);
WPRichText1.InputString ('Word');
WPRichText1.CurrAttr.DeleteStyle([afsBold]);
WPRichText1.InputString (' in bold font');
WPRichText1.EndUpdate;
Which is more versatile and allows to change all other attributes, too.
A 3rd approach is to first add the text (using SelectionAsString) and the create a loop over all characters which you have added to apply 'afsBold' to CPAttr^.Style to the characters which need to be changed.