编译错误:用户定义的类型 [英] Compile Error: User Defined Type
本文介绍了编译错误:用户定义的类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在尝试使用以下VBA将信息从访问中导入excel。这个VBA在excle表中: -
I am currently trying to use the below VBA to import information into excel from access. This VBA is in the excle sheet:-
展开 | 选择 | Wrap | 行号
推荐答案
我目前正在尝试使用以下VBA将信息从访问中导入excel。这个VBA在excle表中: -
I am currently trying to use the below VBA to import information into excel from access. This VBA is in the excle sheet:-
展开 | 选择 | Wrap | 行号
您是从Access或Excel forrestgump执行此操作吗?
Are you doing this from Access, or Excel forrestgump?
我目前在excel中运行此VBA以尝试从访问中提取信息。
I am currently running this VBA in excel to try and pull the information from access.
我目前正在尝试使用以下VBA将信息从访问中导入excel。这个VBA在excle表中: -
Public Sub getrs()
Dim adoconn As ADODB.Connection
Dim adors作为ADODB.Recordset
Dim sql As String
Dim filenm As String
sql =" Select * from Table1"
filenm =" R:\HR \HR_System_Reports_Folder \Databases \HeadCoun t.mdb"
调用GetCn(adoconn,adors,sql,filenm,""," ;")
Dim xlsht As Excel.Worksheet
Set xlsht = Sheets(" Sheet1")
xlsht.Range(" A1)。CopyFromRecordset adors
adors.Close
adoconn.Close
设置adors = Nothing
设置adoconn =没有什么
设置xlsht =没什么
结束子
但是当我尝试使用这段代码时它会说编译错误:用户定义的类型未定义。我不相信我需要在参考文献中记下一些内容,但我不知道是什么。有没有人有任何想法?
I am currently trying to use the below VBA to import information into excel from access. This VBA is in the excle sheet:-
Public Sub getrs()
Dim adoconn As ADODB.Connection
Dim adors As ADODB.Recordset
Dim sql As String
Dim filenm As String
sql = "Select * from Table1"
filenm = "R:\HR\HR_System_Reports_Folder\Databases\HeadCoun t.mdb"
Call GetCn(adoconn, adors, sql, filenm, "", "")
Dim xlsht As Excel.Worksheet
Set xlsht = Sheets("Sheet1")
xlsht.Range("A1").CopyFromRecordset adors
adors.Close
adoconn.Close
Set adors = Nothing
Set adoconn = Nothing
Set xlsht = Nothing
End Sub
However when I try to use this code it says Compile Error: User Defined Type Not Defined. Ibelieve I need to tick somethin in the references section but I do not know what. Has anyone got any ideas?
- 您可能缺少对Microsoft Access XX.X对象库的引用,这可能是错误的原因。
- 您应该实例化指向ADO连接和Recordset对象的对象变量,如下所示:
- You may be missing a Reference to the Microsoft Access XX.X Object Library, this could account for the Error.
- You should Instantiate the Object Variables pointing to the ADO Connection and Recordset Objects as in:
展开 | 选择 | Wrap | 行号
这篇关于编译错误:用户定义的类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文