why errors from Excel object

Posted on 2000-04-17
Last Modified: 2010-05-02
The following command:

    Dim ef1 As New ExcelFile

gives me the error:

    User defined type not defined.

I added the excel library 8.0.  It worked on a different computer using the 9.0 library.  should I be adding more components or references? and what is the different between 8.0 and 9.0?
Question by:cocor
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
  • 3
  • 2
  • +1
LVL 70

Expert Comment

by:Éric Moreau
ID: 2724158
This type doesn't exist in the 8.0 version!

Expert Comment

by:Glen Richmond
ID: 2724933
dim xl As Excel.Application
xl.Workbooks.Open "PathAndFileNameAsString"
this should offer up most properties and methods used.

Expert Comment

ID: 2726005
The way glenrichmond put it is the way to do it, but you have to declare it like this:
Dim xl as New Excel.Application

If you don't you'd have to set the xl variable later on, which is not what you'd want.

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.


Expert Comment

by:Glen Richmond
ID: 2726585
Yeh sorry TheMek missed that out, well spotted.

Author Comment

ID: 2726808
So the proper way to declare an excel file that will work in both excel library 8.0 and 9.0 is this?:

dim xl As New Excel.Application
xl.Workbooks.Open "PathFileNameAsString"

if i don't put "new" will it open an existing excel file or it is declaring the variable xl as a new excel object?

where can i find a list of these methods you mention?
ie.  xl.Cells(R, C).Value =...
LVL 70

Accepted Solution

Éric Moreau earned 50 total points
ID: 2726902
If you don't put the "New", you need a syntax like this:
dim xl As Excel.Application
set xl = new Excel.Application
set xl=CreateObject("Excel.Application")

Try not to put the New on the declaration line.

"where can i find a list of these methods you mention? "
You may look the help file but an easy way I find command of Excel, Word, ... is to record macros!

Author Comment

ID: 2727614
Thankyou for all your help.  This is what I was looking for

Expert Comment

by:Glen Richmond
ID: 2728835
cocor just a quick question why did you choose his answer over mine?

Author Comment

ID: 2731541
I am sorry. I wasn't sure which one to choose.

I knew how to declare an excel object both ways.  I just didn't know exactly what was happening and what was the difference between both types of declarations.  I guess the answer I was looking for was an understanding of the commands and what was the difference of the 8.0 and 9.0

I hope there is no hard feelings.

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Adding to a VBA? 6 94
How to Add / Edit Windows Menu 4 83
Dinamic report to Crosstab query 9 60
Excel Userform to write back to spreadsheet in a different font or colour 8 39
Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

710 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