Board index » cppbuilder » Opening an Excel document...

Opening an Excel document...

Hi folks,

I'm trying to open an excel file but it always fails!!!

ExcelApplication is the TExcelApplication VCL object (Borland C++ Builder
5). The properties are set on Auto Connect as a new Instance.

I can use the ExcelApplication to create a new workbook and even save it but
I just can't open one.
Here is my very simple code.

    Excel_2k::ExcelWorkbookPtr pWb;
    Caption = ExcelApplication->Get_Caption();  // Just for fun and works
without any problems

    pWb = ExcelApplication->Workbooks->Open((BSTR)"C:\\ELFA.xls"); // I get
an error box here

    ExcelApplication->Workbooks->Close();

As you probably understand the document really excist on this location. The
error box "HRCHECK" comes up showing "bla, bla, bla ERROR: C0000005 on line
13141 in the VCL\Excel_2k.h file. Yes I have a working Excel 2000 installed.

Please help...

 

Re:Opening an Excel document...


Sorry folks... I solved the problem myself :)

Quote
"Max Kielland" <max.kiell...@swecoin.se> wrote in message

news:3efa19d6@newsgroups.borland.com...
Quote
> Hi folks,

> I'm trying to open an excel file but it always fails!!!

> ExcelApplication is the TExcelApplication VCL object (Borland C++ Builder
> 5). The properties are set on Auto Connect as a new Instance.

> I can use the ExcelApplication to create a new workbook and even save it
but
> I just can't open one.
> Here is my very simple code.

>     Excel_2k::ExcelWorkbookPtr pWb;
>     Caption = ExcelApplication->Get_Caption();  // Just for fun and works
> without any problems

>     pWb = ExcelApplication->Workbooks->Open((BSTR)"C:\\ELFA.xls"); // I
get
> an error box here

>     ExcelApplication->Workbooks->Close();

> As you probably understand the document really excist on this location.
The
> error box "HRCHECK" comes up showing "bla, bla, bla ERROR: C0000005 on
line
> 13141 in the VCL\Excel_2k.h file. Yes I have a working Excel 2000
installed.

> Please help...

Other Threads