0
A
回答
5
你不需要第三方組件。檢查這些樣品
使用Range
功能至極配備了Text
財產
uses
ComObj;
function ExtractTextFromWordFile(const FileName:string):string;
var
WordApp : Variant;
CharsCount : integer;
begin
WordApp := CreateOleObject('Word.Application');
try
WordApp.Visible := False;
WordApp.Documents.open(FileName);
CharsCount:=Wordapp.Documents.item(1).Characters.Count;//get the number of chars to select
Result:=WordApp.Documents.item(1).Range(0, CharsCount).Text;//Select the text and retrieve the selection
WordApp.documents.item(1).Close;
finally
WordApp.Quit;
end;
end;
或使用剪貼板,你必須選擇所有的文檔內容,複製到剪貼板,並使用檢索數據Clipboard.AsText
uses
ClipBrd,
ComObj;
function ExtractTextFromWordFile(const FileName:string):string;
var
WordApp : Variant;
CharsCount : integer;
begin
WordApp := CreateOleObject('Word.Application');
try
WordApp.Visible := False;
WordApp.Documents.open(FileName);
CharsCount:=Wordapp.Documents.item(1).Characters.Count; //get the number of chars to select
WordApp.Selection.SetRange(0, CharsCount); //make the selection
WordApp.Selection.Copy;//copy to the clipboard
Result:=Clipboard.AsText;//get the text from the clipboard
WordApp.documents.item(1).Close;
finally
WordApp.Quit;
end;
end;
相關問題
- 1. 解析Word(.doc /.docx)文檔
- 2. 將PDF文檔(* .pdf)轉儲到文本?
- 3. 將pdf轉換爲word doc文件
- 4. 如何使用Freemarker將XML Word文檔轉換爲DOC?
- 5. 如何將文檔從.doc文件轉換爲文本
- 6. 存儲word文檔
- 7. 將Word文檔保存爲「Word文檔」
- 8. 將pdf文件轉換爲word文檔
- 9. DOC到XPS文件文檔
- 10. 將文本寫入Word文檔
- 11. 使用PHP將Word文檔添加到另一個Word文檔
- 12. 在轉換Word文件(DOC/DOCX),以HTML文本
- 13. 將Excel文件中的文本插入Word文檔(Word VBA)
- 14. 如何將舊的MS Word文檔轉換爲純文本?
- 15. 將Word文檔文本轉換爲HTML的庫
- 16. 將網頁上的文本註釋轉換爲word文檔
- 17. VBA:將文本文件中的行復制到Word文檔中
- 18. 將Word文檔轉換爲EPUB
- 19. 將HTML轉換爲Word文檔
- 20. 將PDF轉換成Word文檔
- 21. 將word文檔轉換爲pdf的vbscript
- 22. 。將HTML轉換爲word文檔
- 23. 將Word文檔轉換爲PDF - Python
- 24. 將word文檔轉換爲pdf
- 25. 快速將Word文檔轉換爲HTML
- 26. 將Word文檔轉換爲HTML格式
- 27. 將Word文檔轉換爲ASPX?
- 28. 將word文檔轉換爲excel
- 29. 將Word文檔轉換爲tiff
- 30. Word文檔到mathml?
That Works!非常感謝! – IElite 2010-11-27 13:19:47