procedure TForm1.Button1Click(Sender: TObject);
var
wordapp,MyRange,mytable: OLEVariant;
begin
try
wordapp := CreateOleObject('Word.Application');
except
on e:exception do begin
Application.MessageBox('Error al crear el documento. Primeramente debe instalar el Office.', pchar(Self.Caption), MB_ICONINFORMATION);
exit;
end;
end;
wordapp.WordBasic.FileNew;
wordapp.Selection.TypeParagraph;
MyRange:=wordapp.ActiveDocument.Range(0,0);
mytable := wordapp.ActiveDocument.Tables.Add(MyRange, 4, 2);
{Change table column width and row height error!!}
// Column width
// mytable.Columns.Item(1).SETWidth (50,0); //wdAdjustNone
// mytable.Columns.Item(1).SETWidth (300,0);
//rows height
// mytable.Rows.Item(1).SetHeight(220,0); // wdAdjustNone
// mytable.Rows.Item(2).SetHeight(120, 0);
// merge
mytable.cell(1, 1).merge(mytable.cell(1, 2));
mytable.cell(2, 1).merge(mytable.cell(2, 2));
mytable.Borders.InsideLineStyle :=1;
mytable.Borders.OutsideLineStyle := 1;
wordApp.Visible := True;
end;