ellenf
asked on
Using VB 5.0 to automate Excel 5.0
Is it possible to automate Excel 5.0 from VB 5.0?
I am writing a small VB application which needs to be able to open an Excel spreadsheet, select specific cells and read the data they contain. I have successfully managed to automate this using Excel 8.0 but when I try it with Excel 5.0, I get run time error 430 "Class doesn't support automation".
I noticed in the VB help that the syntax for referring to the Excel application class is "set oexcel = new excel.application" for Excel 8.0 but "set oexcel = new [_excelapplication] for Excel 5.0 but I still can't get it to work even though I've taken this into account.
I'm not doing anything particularly flash when referencing the Excel object, just things like oExcel.Workbooks.Open(sFil eName).Act ivate and oExcel.Cells(3, 3).Select
Any help would be greatly appreciated.
I am writing a small VB application which needs to be able to open an Excel spreadsheet, select specific cells and read the data they contain. I have successfully managed to automate this using Excel 8.0 but when I try it with Excel 5.0, I get run time error 430 "Class doesn't support automation".
I noticed in the VB help that the syntax for referring to the Excel application class is "set oexcel = new excel.application" for Excel 8.0 but "set oexcel = new [_excelapplication] for Excel 5.0 but I still can't get it to work even though I've taken this into account.
I'm not doing anything particularly flash when referencing the Excel object, just things like oExcel.Workbooks.Open(sFil
Any help would be greatly appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your help.
I put your suggestions into my code and ran it on my machine which has Excel 8.0 on it and it ran ok whereas before I kept getting an automation error. I still need to try it on a machine that has Excel 5.0 on it but I'm optimistic that it will work.
I put your suggestions into my code and ran it on my machine which has Excel 8.0 on it and it ran ok whereas before I kept getting an automation error. I still need to try it on a machine that has Excel 5.0 on it but I'm optimistic that it will work.
Make sure that you haven't accidently put the version number when you dimension your object. For example, you could use the following Dim statement:
Dim xlNew as Excel.Application.8
and this would specifically open Excel version 8 but would fail when you run it on a machine with Excel 5. Make sure you use:
Dim xlNew as Excel.Application
Good luck.