光急不行啊,要认真研究一下才可以的
一下是正确的代码:
var
FileName: String;
o: Object;
app, docs, doc, tbl, row: System.DispatchHelper;
begin
FileName := 'c:\1.doc';
o := ComObj.CreateOleObject('Word.Application');
app := DispatchHelper.Create(o);
app.PropertyPut('Visible', [True]);
docs := DispatchHelper.Create(app.PropertyGet('Documents', []));
// docs.InvokeMethod('Open', []);
docs.InvokeMethod('Add', [FileName,False]);
doc := System.DispatchHelper.Create(app.PropertyGet('ActiveDocument',[]));
tbl := System.DispatchHelper.Create(doc.PropertyGet('Tables',[]));
tbl := System.DispatchHelper.Create(tbl.InvokeMethod('Item', [1]));
row := System.DispatchHelper.Create(tbl.PropertyGet('Rows',[]));
row := System.DispatchHelper.Create(row.InvokeMethod('Item', [1]));
row.InvokeMethod('Delete', []);
(o as System.IDisposable).Dispose;
end; |