Delphi with Word (3) Data for Word files

zhaozj2021-02-17  49

// get data procedure getWordStr Word document; var WordApp: TWordApplication; ??? WordDoc: TWordDocument; ??? DocInx, oFileName, CfCversions, oReadOnly, AddToRctFiles, PswDocument, ??? PswTemplate, oRevert, WPswDocument, WPswTemplate, oFormat: Olevariant; ??? I, irow, icol: integer; ??? mycell: cell; ??? mycent: rot; begin? MEMO1.LINES.CLEAR

??? // ===== 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; ??? o format: = EmptyParam; ???? ??? // ===== Open file ===== ?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ????? ??? Wordapp.Documents.open (OfileName, Cfcvers, Oradonly, AddtorctFiles, ?????? pswdocument, pswinterplate, orevert, wpswdocument, wpswtemplate, OFORMAT); ??? // ==== = Related file ===== ??? WordDoc.connectto (Wordapp.Documents.Item (Docinx));

??? // method (1): Take the character content of the entire text, contain the table ??? s: = worddoc.range.text ;?

??? // method (2): Take 1 - 4 characters, including the table ??? myrange: = worddoc.range; ??? myrange.Start: = 0; ??? myrange.end_: = 4 ;

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

New Post(0)