Solved

why errors from Excel object

Posted on 2000-04-17
9
145 Views
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?
Thanks
0
Comment
Question by:cocor
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 69

Expert Comment

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

Expert Comment

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

Expert Comment

by:TheMek
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.

Greetings,
  Erwin
0
 
LVL 2

Expert Comment

by:Glen Richmond
ID: 2726585
Yeh sorry TheMek missed that out, well spotted.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:cocor
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 =...
       
0
 
LVL 69

Accepted Solution

by:
É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
-or-
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!
0
 

Author Comment

by:cocor
ID: 2727614
Thankyou for all your help.  This is what I was looking for
0
 
LVL 2

Expert Comment

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

Author Comment

by:cocor
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.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

861 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now