?
Solved

Using VB 5.0 to automate Excel 5.0

Posted on 1998-02-19
3
Medium Priority
?
225 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 200 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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

800 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