I have a program that connects to an open Excel file via TExcelApplication and creates a worksheet.
When I have the windows preview pane activated, then I "previewed" my workbook, then I opened the workbook, and launched my App, the program returns the following error: 'Error OLE 800A03EC'
In the windows process, I have 2 instances of excel, one of which has as an argument: "Embedding" I think Delphi is trying to connect to the wrong instance.
How to connect to the good?
Here is the minimalist code that reproduces the problem:
procedure TForm1.Button1Click( Sender : TObject );
var
Excel : TExcelApplication;
begin
try
Excel := TExcelApplication.Create( Self );
Excel.ConnectKind := ckRunningInstance;
Excel.Connect;
Excel.Workbooks.Add( xlWBATWorksheet, 0 );
except
on E : Exception do
begin
ShowMessage( E.Message );
end;
end;
end;
end.
Pictures to better understand what I'm talking about:
Thank you in advance.
Tristan