Compiler Error: User-defined types not defined

后端 未结 3 555
慢半拍i
慢半拍i 2020-11-30 08:35

I get the compile-time error \"User-defined types not defined\" on this line:

Dim cn As ADODB.Connection

What could be wrong?

Code:

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-30 09:23

    You can use late binding:

    Dim cn As Object
    

    will make the problem go away. VBA will make the reference automatically when the Set cn = CreateObject("ADODB.Connection") statement is executed.

提交回复
热议问题