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

I am trying to open an Excel Excel 2003 workbook and save it as something else, such as excel 95. I am using 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 the client computer, while it works on mine. Note that I have Office 2007 installed and it has Office 2003 SP3.

Any help would be greatly appreciated.

+4
source share
5 answers

I saw this error once while automating Excel. This happened when the user had a cell in editmode and you tried to automate this instance. Excel doesn't like it when you edit a cell, and some program runs in the background.

So this is what happens with your client (I think):

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

How can you prevent this: set the ConnectKind of your TExcelApplication to ckNewInstance so that you always work in a separate instance of Excel.

+9
source

800A03EC also occurs when one (like me) is doing a stupid thing, for example, trying to load into an Excel cell that does not exist, for example:

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

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

+2
source

OLE 800A03EC usually deals with invalid characters in your Excel file. Do you use the same data as your client? Is there a difference in regional settings? Etc. Etc. There can be a lot of errors for this, but most likely (as a quick google told me), this is a regional setting.

+1
source

In my case (xlExcel8 format):

Instead:

 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 works!

+1
source

I get this error when trying to save too much data in WorkSheet (via Delphi)

0
source

Source: https://habr.com/ru/post/1302735/


All Articles