Ole 800A03EC error when using TExcelWorkBook SaveAs method in Delphi 7

40,901

Solution 1

I have seen this error once when automating Excel. It happened when the user had a cell in editmode and you tried to automate that instance. Excel doesn't like it when you are editing a cell and some program is fiddling around in the background.

So this is what's happening at your client (I think):

  • Your client has Excel open and is editing a cell (select a cell and press F2)
  • Your code starts:
    • You create a TExcelApplication and accesses the Workbooks property. Since your Excel application is not yet connected it calls TOleServer.Connect (look at the implementation of GetDefaultInterface)
    • Since the default connectkind is ckRunningOrNew, TExcelApplication connects to the running instance.
    • Because the client is editing a cell you get an error on the Open method.

How you can prevent this: Set ConnectKind of your TExcelApplication to ckNewInstance so you'll always work in a separate Excel instance.

Solution 2

800A03EC also occurs when one (like, me) does a dumb thing like trying to load into an Excel cell that doesn't exist, like:

excel.Cells[rowIndex, ri] = x;
where ri is 0.

NOTE BENE: The col index starts at 1, not 0.

Solution 3

I'm getting that error when trying to store too much data to the WorkSheet (through Delphi)

Solution 4

In my case ( xlExcel8 format ):

Instead of:

theWorkbookWyjscie.SaveAs(saveFileDialog1.FileName, myExcel.XlFileFormat.xlExcel8);

I used:

theWorkbookWyjscie.SaveAs(saveFileDialog1.FileName);

or

theWorkbookWyjscie.SaveAs(saveFileDialog1.FileName, myExcel.XlFileFormat.xlExcel7);

Both work well... And yes, I know this is a stupid solution, but it's working!

Solution 5

OLE 800A03EC usually has to do with invalid characters in your Excel file. Are you using the same data as your client? Is there a difference in Regional Settings? Etc. etc. there could be number of errors for this, but most likely (as a quick google told me) it is a regional setting.

Share:
40,901
Tofig Hasanov
Author by

Tofig Hasanov

My main area of interest is Computer Science; however, I have also spent at least several years studying and practicing each of the following fields: 1) Psychology - particularly psychoanalysis, group dynamics and psychology of masses 2) Philosophy - Mostly interested in practical aspects, such as dialectical logic 3) Personal Development - Some might not classify it as a separate field of study, but I have spent more than 10 years doing research and consulting in this area and I know how deep and fascinating this field is. 4) Business Management - Systems and Control theory. Spent a lot of time working on startups as well. 5) Education - Tought Machine Learning, Algorithms and Data Structures and Engineering Design classes to undergraduate students in Qafqaz University. 6) Gaming - I have played lots of games, and I have studied them as well. I believe that we can borrow a lot of tricks from successful games, especially in the area of motivation, and implement them in education and other areas. As for computer science itself, my main focus is Machine Learning, Multi-Agent Systems and Crowdsourcing. It might seem that all these subjects are completely unrelated, but they are all united in the goal to understand various aspects of human mind: how we think, how we learn, how we motivate ourselves, etc. This is what excites me most. I think that to make the world a better place, we should start with understanding and improving ourselves.

Updated on July 09, 2022

Comments

  • Tofig Hasanov
    Tofig Hasanov almost 2 years

    I am trying to open excel 2003 workbook and save it as something else, for example excel 95. I use the following code:

    XLSApp:=TExcelApplication.Create(Self);
    XLSApp.Workbooks.Open(SomeFileName,NULL,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,defaultlcid);
    XLSWB:=TExcelWorkbook.Create(XLSApp);
    XLSWB.ConnectTo(XLSApp.Workbooks.Item[1]);
    XLSWB.SaveCopyAs(ExtractFilePath(edTable.Text)+'temp.xls');
    XLSWB.SaveAs(SomeOtherFileName,xlExcel7,EmptyParam,EmptyParam,False,False,xlNoChange,xlUserResolution,False,EmptyParam,EmptyParam,EmptyParam,DefaultLCID);
    

    Unfortunately this code gives "Ole 800A03EC" on clients computer, while it works on mine. Note that I have Office 2007 installed, and he has Office 2003 SP3.

    Any help would be very much appreciated.