Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

error:User defined type not defined

Posted on 2006-07-15
5
Medium Priority
?
371 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 2000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

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…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) 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…
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…
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…
Suggested Courses

916 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