Kamyar Kimiyabeigi
Kamyar Kimiyabeigi

Reputation: 99

paste with delphi in ole automation

i want paste in delphi from richedit to word application i used Following code but Twice paste data in word (duplicate)

  WordApp := GetActiveOleObject('Word.Application');
  WordApp.Visible := True;
  Wordapp.documents.open('C:\Doc1.docx');
  Richedit.Text := 'test text';
  Richedit.SelectAll;
  Richedit.CopyToClipboard;
  WordApp.ActiveDocument.ActiveWindow.Selection.Paste;
  WordApp.selection.paste;

Upvotes: 1

Views: 1720

Answers (2)

Chris Thornton
Chris Thornton

Reputation: 15817

Are you trying to end up with this?

test text
test text

But only getting this?

test text

If so, then maybe the "selection" is causing it to paste the same data into the same selection, thus the 2nd paste wipes out the first one.

Upvotes: 0

David
David

Reputation: 1529

Try leaving out the last line of your code

Upvotes: 7

Related Questions