执行以下代码行后,我得到EoleSysError异常:
FContainer.DoVerb(ovShow);
当我打开表单中的多个Word文档时,不会发生异常。 这是例外情况的图片。 出于某些原因,当我想以以下格式打开Excel文件时出现错误:
这是我当前的代码:
procedure TForm1.FormActivate(Sender: TObject);
var
FDocument, FWord:Variant;
FContainer: TOleContainer;
begin
FContainer := TOleContainer.Create(olecontainer1);
FContainer.Modified := false;
FContainer.Parent := olecontainer1;
FContainer.Align := alClient;
FContainer.CreateObject('Word.Document', true);
FDocument := IDispatch(FContainer.OleObject);
FWord := FDocument.Application;
FContainer.DoVerb(ovShow);
// olecontainer2
FContainer := TOleContainer.Create(olecontainer2);
FContainer.Modified := false;
FContainer.Parent := olecontainer2;
FContainer.Align := alClient;
FContainer.CreateObject('Excel.Application', true);
FDocument := IDispatch(FContainer.OleObject);
FWord := FDocument.Application;
FContainer.DoVerb(ovShow);
FContainer := TOleContainer.Create(olecontainer3);
FContainer.Modified := false;
FContainer.Parent := olecontainer3;
FContainer.Align := alClient;
FContainer.CreateObject('Word.Document', true);
FDocument := IDispatch(FContainer.OleObject);
FWord := FDocument.Application;
FContainer.DoVerb(ovShow);
FContainer := TOleContainer.Create(olecontainer4);
FContainer.Modified := false;
FContainer.Parent := olecontainer4;
FContainer.Align := alClient;
FContainer.CreateObject('Excel.Application', true);
FDocument := IDispatch(FContainer.OleObject);
FWord := FDocument.Application;
FContainer.DoVerb(ovShow);
end;