由于对WORD的操作,DispatchHelper的调用方法不清楚,不知该如何插入数据,请帮助解决?谢谢。
var
FileName: String;
O: Variant;
app, docs, doc,: System.DispatchHelper;
begin
FileName := 'D:\aaa.doc';
if not FileExists(FileName) then
raise Exception.Create('找不到模板!');
O := ComObj.CreateOleObject('Word.Application');
try
app := System.DispatchHelper.Create(o);
app.PropertyPut('Visible', [True]);
docs := System.DispatchHelper.Create(app.PropertyGet('Documents', []));
docs.InvokeMethod('Add', [FileName,False]);
doc := System.DispatchHelper.Create(app.PropertyGet('ActiveDocument',[]));
[B]//我打开的WORD文档中有个2行2列的表格,我想给每个单元格中存放内容,怎么实现?//[/B]
(o as System.IDisposable).Dispose;
except
Jsdialogs.ShowMsg('创建WORD对象失败','');
end;
end; |