开发者

QueryTables error

I have the following VBA code inside an Excel macro:

With ActiveSheet.QueryTables.Add( _
    Connection:=ConnStr, _
    Destination:=ActiveSheet.Range("A1"), _
    Sql:=SqlStr)
        .Refresh
End With

And yet I am getting the error: "Run-time error '1004': Application-defined or object-defined error." The debugger points to this code as the source of error.

Ass开发者_如何学编程uming that my ConnStr and SqlStr are correct, why am I getting this error? I am using Excel 2007 and I am querying an Oracle database.


Thanks for the reply, Adam. I managed to fix the problem. The problem was with my Connection and SQL strings. I needed to prepend "ODBC" to my conn string, and then I needed to add some spaces to my SQL string. I forget which caused the error.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜