定义了 Dim cn As ADODB.Connection
执行后就报错 " 编译错误: 用户定义类型未定义"
答:
按Alt+F11打开代码窗口,点击菜单上的"工具">>"引用",勾选它:Microsoft ActiveX Da
然后利用下面的代码进行调用:
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
With cn
.Provider = "microsoft.jet.oledb.4.0"
.ConnectionString = "extended properties=excel 8.0;" _
& "da
.Open
End With