// 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;