Solved

error:User defined type not defined

Posted on 2006-07-15
5
335 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
  • 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

746 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

11 Experts available now in Live!

Get 1:1 Help Now