用ADO 连接excel时,提示应用程序定义错误,大侠请帮忙看下问题在哪里???

2025-01-02 20:27:41
推荐回答(1个)
回答1:

Sub AdoCnnFile()
Dim cnn As New ADODB.Connection
cnn.Open "provider=Microsoft ACE OLEDB.12.0;data source=F:\ExcelVBA练习\PDR文件夹\pdr-6月.xlsx"
ThisWorkbook.Sheets(1).[a1].CopyFromRecordset cnn.Execute("select * from [sheet1$a:j]")
Set cnn = Nothing
End Sub
''你怎么能写那么长?连接字符串多了xml,select语句错误
''有效请采纳