Solved

Using VB 5.0 to automate Excel 5.0

Posted on 1998-02-19
3
223 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…

689 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