Solved

error:User defined type not defined

Posted on 2006-07-15
5
350 Views
Last Modified: 2009-12-16
Hi,

Please assist what could be missing, vb returns the error: User defined type not defined

pointing to the following line:
Private Function GetExcelConnection(ByVal Path As String, Optional ByVal Headers As Boolean = True) As Connection

Thanks.
0
Comment
Question by:RyanBank
[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
  • 2
5 Comments
 
LVL 44

Expert Comment

by:bruintje
ID: 17113756
Hi RyanBank,
----------

think its missing the reference to the connection type, the function returns a connection but where is Connection delcared?

----------
bruintje
0
 

Author Comment

by:RyanBank
ID: 17113759
bruintje,

here's the whole function with the connection type. what could be happening?

thanks.

Private Function GetExcelConnection(ByVal Path As String, Optional ByVal Headers As Boolean = True) As Connection
    Dim strConn As String
    Dim objConn As ADODB.Connection
    Set objConn = New ADODB.Connection
    strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
              "Data Source=" & Path & ";" & _
              "Extended Properties=""Excel 8.0;HDR=" & _
              IIf(Headers, "Yes", "No") & """"
    objConn.Open strConn
    Set GetExcelConnection = objConn
End Function
0
 
LVL 44

Accepted Solution

by:
bruintje earned 500 total points
ID: 17113762
you probably did add a reference to the microsoft active data objects library

then your code should work or try an explicit cast to the ado connection type

Private Function GetExcelConnection(ByVal Path As String, Optional ByVal Headers As Boolean = True) As ADODB.Connection
    Dim strConn As String
    Dim objConn As ADODB.Connection
    Set objConn = New ADODB.Connection
    strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
              "Data Source=" & Path & ";" & _
              "Extended Properties=""Excel 8.0;HDR=" & _
              IIf(Headers, "Yes", "No") & """"
    objConn.Open strConn
    Set GetExcelConnection = objConn
End Function

0
 

Author Comment

by:RyanBank
ID: 17113878
bruintje,

can you kindly assist, i'm out of luck on this one:

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21920356.html


thanks
0
 
LVL 44

Expert Comment

by:bruintje
ID: 17114449
sorry i was out with the family, but i see your problem was already solved
0

Featured Post

Revamp Your Training Process

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

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Suggested Courses
Course of the Month7 days, 5 hours left to enroll

623 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