views:

63

answers:

2

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;
+6  A: 

Try leaving out the last line of your code

David
Calling 'Paste' twice should give you a hint of whats happening..
Vegar
A: 

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.

Chris Thornton