Solved

Using VB 5.0 to automate Excel 5.0

Posted on 1998-02-19
3
217 Views
Last Modified: 2012-05-04
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(sFileName).Activate and         oExcel.Cells(3, 3).Select

Any help would be greatly appreciated.
0
Comment
Question by:ellenf
3 Comments
 
LVL 6

Accepted Solution

by:
anthonyc earned 50 total points
ID: 1457531
Ellen,

I've automated excel 5.0, and didn't notice anything was different.  I do this:

1)  Add a reference for Microsoft Excel 5.0 Object Lib

2)  
  Dim xlNew As Excel.Application
  Set xlNew = CreateObject("excel.application")

  xlNew.Visible = True
  xlNew.Workbooks.Open("c:\anthony\personal\phone list.xls").Activate


and this opens my phone book, without a problem.
0
 

Expert Comment

by:bwood
ID: 1457532
Ellen,
    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.
0
 

Author Comment

by:ellenf
ID: 1457533
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.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question