AdvRichEditor replace selection and hyperlink

Hi,
how to replace a selected text and then make it a hyperlink? 


UnicodeString ustr = FreeTextAdvRichEditor->SelectedText();

ustr = StringReplace(ustr, ":\", "|\", TReplaceFlags() << rfReplaceAll);
ustr = StringReplace(ustr, " ", "%20", TReplaceFlags() << rfReplaceAll);

I've tried these but I cannot make it work. :( 
// FreeTextAdvRichEditor->DeleteSelection();
// FreeTextAdvRichEditor->InsertText(ustr);
// FreeTextAdvRichEditor->SelectWordAtCaret();
FreeTextAdvRichEditor->SetSelectionHyperlink(ustr);

Kind regards,
Lars
 

I got it working now. 


BR,
Lars

Thanks for informing.