Solved

Using VB 5.0 to automate Excel 5.0

Posted on 1998-02-19
3
214 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

777 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