Delphi and Word (1) Merge Word Table

xiaoxiao2021-03-06  54

// Merge Word table cell procedure mergeWordCell; 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 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; 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));

// Merge first, second column iStart: = WordDoc.tables.Item (i) .Cell (1, 1) .range.start; mycol: = worddoc.tables.Item (i) .Columns.Item (2); IEND: = mycol.cells.item (mycol.cells.count) .range.end_; myrange: = worddoc.range; myrange.start: = iStart; myrange.end_: = Iend; myrange.cells.mege;

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

New Post(0)