我在ole容器中打开了一个word文档。我想选择所有文本(Ctrl-A)然后复制到剪贴板而不使用击键。
所需的第二个功能是保存对文档所做的任何更改。
答案 0 :(得分:0)
也许这段代码可以帮助您:
uses ComObj, Clipbrd;
...
var
Word : OLEVariant;
begin
Word := CreateOleObject('Word.Application');
// If you do not want to see word, set it to false.
Word.Visible := False;
//Open the word document.
Word.Documents.Open('C:\myDocument.doc');
//Select all.
Word.ActiveDocument.Select;
//Copy to Clipboard.
Word.ActiveDocument.Range.Copy;
//Close the document.
Word.ActiveDocument.Close;
//Quit word.
Word.Quit;
//Free.
Word := unassigned;
//Now you can paste the text from clipboard.
Memo1.PasteFromClipboard;
end;