Delphi with Word (3) Data for Word files

xiaoxiao2021-03-06  56

// data acquisition procedure getWordStr Word documents; var WordApp: TWordApplication; WordDoc: TWordDocument; DocInx, oFileName, CfCversions, oReadOnly, AddToRctFiles, PswDocument, PswTemplate, oRevert, WPswDocument, WPswTemplate, oFormat: OleVariant; i, iRow, iCol: integer ; Mycell: cell; myrow: row; begin membain;

/ / ===== Create an object ===== if Not Assigned (WordApp) Then Begin Wordapp: = TWORDAPPLICATION.CREATE (NIL); Wordapp.Visible: = false; end; if not assigned (WordDoc) THEN WordDoc: = TWordDocument.Create (nil); try DocInx: = 1; oFileName: = 'd: /test.doc'; oReadOnly: = true; CfCversions: = EmptyParam; AddToRctFiles: = EmptyParam; PswDocument: = EmptyParam; PswTemplate: = EmptyParam ; oRevert: = EmptyParam; WPswDocument: = EmptyParam; WPswTemplate: = EmptyParam; oFormat: = EmptyParam; // ===== open the file ===== WordApp.Documents.open (oFileName, CfCversions, oReadOnly, AddToRctFiles, PswDocument , Pswtemplate, Orevert, WPswdocument, WPSWTemplate, OFORMAT, / / ​​===== Associated file ===== WordDoc.connectto (Wordapp.Documents.Item (Docinx));

// Method (1): Take the character content of the entire text, including the table S: = WordDoc.range.Text;

// Method (2): Take 1 - 4 characters, including table myrange: = worddoc.range; myrange.start: = 0; myrange.end_: = 4;

转载请注明原文地址:https://www.9cbs.com/read-119067.html

New Post(0)