Solved

Using VB 5.0 to automate Excel 5.0

Posted on 1998-02-19
3
208 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now