我正在尝试使用ADODB方式将csv加载到VBA中的2D数组:
Function LoadCSVtoArray(strPath As String) As Variant()
Set cn = CreateObject("ADODB.Connection")
strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath & _
";Extended Properties=""text;HDR=Yes;FMT=Delimited(,)"";"
cn.Open strcon
Set cmd = CreateObject("ADODB.Command")
cmd.ActiveConnection = cn
cmd.CommandType = adCmdTable
cmd.CommandText = "mytable#csv"
Dim rs As Recordset
Dim rsARR() As Variant
Set rs = cmd.Execute
rsARR = WorksheetFunction.Transpose(rs.GetRows)
Set cn = Nothing
LoadCSVtoArray = rsARR
End Function
当我到达cmd.Execute
行时,我收到以下错误消息:
我在这里缺少哪些明显的东西?
我已经验证了该路径,并且我确信该文件夹中存在mytable.csv
。