Tables.Count
tables[i].columns.count
tables[i].rows.count

解决方案 »

  1.   

    var
        S,Word,  Doc,  Table:  OleVariant;
    begin
        word:=CreateOleObject('Word.Application');//start  word
        word.Visible:=false;    //set  visible
        Doc:=Word.Documents.Add;    //add  a  new    document
        Doc  :=  Word.ActiveDocument;
        Doc.Tables.Add(Doc.Range(0,  0),4,4);    //add  a    4×4  table
        Table  :=  Doc.Tables.Item(1);        // get  table    index=1
        Table.Cell(1,  1).Range.Text  :='hello';    //set  text
        showmessage(inttostr(table.rows.count));
        showmessage(inttostr(table.columns.count));
        showmessage(inttostr(doc.tables.count));
        doc.saveas('c:\a.doc');    //save
        doc.close; 
        word.quit;
        word:=Unassigned;
    end;