Solved

error:User defined type not defined

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

734 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