why errors from Excel object

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?
Who is Participating?
Éric MoreauConnect With a Mentor Senior .Net ConsultantCommented:
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!
Éric MoreauSenior .Net ConsultantCommented:
This type doesn't exist in the 8.0 version!
Glen RichmondCustomer Reporting Programmer.Commented:
dim xl As Excel.Application
xl.Workbooks.Open "PathAndFileNameAsString"
this should offer up most properties and methods used.
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

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.

Glen RichmondCustomer Reporting Programmer.Commented:
Yeh sorry TheMek missed that out, well spotted.
cocorAuthor Commented:
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 =...
cocorAuthor Commented:
Thankyou for all your help.  This is what I was looking for
Glen RichmondCustomer Reporting Programmer.Commented:
cocor just a quick question why did you choose his answer over mine?
cocorAuthor Commented:
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.