在ole自动化中用delphi粘贴
我想在delphi中从richedit粘贴到word应用程序 我使用了以下代码,但两次将数据粘贴到word中(重复)
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;
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;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试省略代码的最后一行
Try leaving out the last line of your code
你想以此结束吗?
但只得到这个?
如果是这样,那么“选择”可能会导致它将相同的数据粘贴到相同的选择中,因此第二个粘贴会擦除第一个粘贴。
Are you trying to end up with this?
But only getting this?
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.