using
COM:
Delphi-Quellcode:
uses
ComObj;
procedure TForm1.Button1Click(Sender: TObject);
var
WordApp : OleVariant;
Doc : OleVariant;
Sel : OleVariant;
begin
WordApp := GetActiveOleObject('Word.Application'); // Connect to open Word
try
try
Doc := WordApp.ActiveDocument;
Sel := Doc.ActiveWindow.Selection;
Edit1.Text := Sel.Text;
// or simple
Edit1.Text := WordApp.ActiveDocument.ActiveWindow.Selection.Text;
except
WordApp.Visible := true;
end;
finally
WordApp := Unassigned; // Disconnect
end;
end;
You did't need the Clipboard!