Connecting to an Excelsheet

I want to read some Cells from an Excelsheet. The code below:

procedure TForm1.OpenExcel;
var     ExcelApp : OLEVariant;
        ExcelWorkbook : OLEVariant;
        ExcelSheet : OLEVariant;
        ExcelRange : OLEVariant;
    ExcelApp := CreateOLEObject ('Excel.Application');
        ExcelApp.Workbooks.Open ('C:\Temp\Temp.xls');
        ExcelWorkbook := ExcelApp.ActiveWorkbook;
        ExcelSheet := ExcelWorkbook.ActiveSheet;
        ExcelRange := ExcelSheet.Range ('A1:A1');
        ShowMessage (ExcelRange.Value);

The result is that I'am able to open this excelfile, but Range ('A1:A1') gives me the error "member not found". I use Excel2000. Where is the mistake?

Thanks a lot for help.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

try changing this...

ExcelRange := ExcelSheet.Range ('A1:A1');

to this...

ExcelRange := ExcelSheet.Range['A1:A1'];

I know this works in Delphi 4 using OLEVariants as I just finished beating a small application into submission to do this kinda crap ;)

hope this helps

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Hi bussoftware,

   Search for a unit named ads_excel at

bussoftwareAuthor Commented:
Yes, this helped avoiding desperation. Your proposal also works with D5. I tried the new servers in D5, but got an OLE error when opening an excelfile. I think the way described above is the better.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.