FileName := 'Documents and SettingsAdministratorApplication DataMicrosoftTemplates1.dot';
if not FileExists(FileName) then
raise Exception.Create('找不到模板!');
O := ComObj.CreateOleObject('Word.Application');
try
app := System.DispatchHelper.Create(O);
docs := System.DispatchHelper.Create(app.PropertyGet('Documents',[]));
docs.InvokeMethod('Add', [FileName,False]);
doc := System.DispatchHelper.Create(app.PropertyGet('ActiveDocument',[]));
app.PropertyPut('Visible', [True]);
//doc.InvokeMethod('Save',[]);
doc.InvokeMethod('SaveAs',['F:Temp.doc',0,False,'',True,'',False,False,False,False,False]);
偶想用这串生成个Word文档,然后将它保存起来,但运行到最后一句时,就报错!
请教怎么解决?先谢过.
|