2

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:

Excel's processes

Windows Preview Pan

Thank you in advance.

Tristan

Tom Brunberg
  • 20,312
  • 8
  • 37
  • 54
  • What is `xlWBATWorksheet`? – Jerry Dodge Dec 01 '17 at 15:58
  • It's just an enum to create a WorkSheet : https://msdn.microsoft.com/fr-fr/library/microsoft.office.interop.excel.workbooks.add.aspx This code is fully functionnal without Windows Preview Pan – Tristan Kahn Dec 01 '17 at 16:12
  • Oh apologies, I thought it was some variable or constant of your own. – Jerry Dodge Dec 01 '17 at 16:15
  • 1
    Seems the ole error you are getting is similar to this post --> https://stackoverflow.com/questions/2355998/ole-800a03ec-error-when-using-texcelworkbook-saveas-method-in-delphi-7 – Ross Bush Dec 01 '17 at 19:42
  • We have the same error, but it's not the same problem : without the preview pane all is functional – Tristan Kahn Dec 08 '17 at 08:34

0 Answers0