简体   繁体   中英

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;

尝试省略代码的最后一行

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM