Words are saved as TXT text and RTF files.

Source: Internet
Author: User

Use OLE to convert Word to text format

Function wordtotxt (sdocfile: string): string; var wordapp: variant; begin wordapp: = createoleobject ('word. basic '); if not varisempty (wordapp) then begin try wordapp. fileopen (sdocfile); Result: = changefileext (sdocfile, '.txt '); wordapp. filesaveas (result, 2); // 2 indicates the text in the format. See the following table wordapp. appclose; finally wordapp: = unassigned; end;

There is a problem, the screen will flash, because the word is opened and closed.

The definition of file format is as follows:

Wdformatdocument 0 Microsoft Office Word format.
Wdformatdostext 4 Microsoft DOS text format.
Wdformatdostextlinebreaks 5 Microsoft DOS text with line breaks preserved.
Wdformatencodedtext 7 Encoded text format.
Wdformatfilteredhtml 10 Filtered HTML format.
Wdformathtml 8 Standard HTML format.
Wdformatrtf 6 Rich Text Format (RTF ).
Wdformattemplate 1 Word template format.
Wdformattext 2 Microsoft Windows text format.
Wdformattextlinebreaks 3 Windows text format with line breaks preserved.
Wdformatunicodetext 7 Unicode text format.
Wdformatwebarchive 9 Web Archive format.
Wdformatxml 11 Extensible Markup Language (XML) format.
Wdformatdocument97 0 Microsoft Word 97 document format.
Wdformatdocumentdefault 16 Word default document file format. For Microsoft Office Word 2007, this is the docx format.
Wdformatpdf 17 PDF format.
Wdformattemplate97 1 Word 97 template format.
Wdformatxmldocument 12 XML document format.
Wdformatxmldocumentmacroenabled 13 XML document format with macros enabled.
Wdformatxmltemplate 14 XML template format.
Wdformatxmltemplatemacroenabled 15 XML template format with macros enabled.
Wdformatxps 18 XPS format.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.