TMemo や TRichEdit の SelText プロパティを変更した場合、Undo() メソッドでは変更前の状態に戻りません。
AnsiString text = "文字列";
Memo1->SelText = text;
Memo1->Undo(); //戻らない
Undo可能にするには、EM_REPLACESEL を SendMessage() で送ります。
AnsiString text = "文字列";
SendMessage(Memo1->Handle, EM_REPLACESEL, TRUE, (LPARAM)text.c_str());
Memo1->Undo(); //戻る