简体   繁体   English

QueryTables.Add应用程序错误

[英]QueryTables.Add application error

Sorry if this is quite a basic q - vb is definitely not where I spend the majority of my time... 抱歉,如果这是一个基本的问题-vb绝对不是我花费大部分时间的地方...

Here's the code I'm stuck on - (Excel 2007) 这是我坚持的代码-(Excel 2007)

    Set qt = ActiveSheet.QueryTables.Add(Connection:=str1, Destination:=Range("Schedule!A4"), Sql:=SQLSTRING)
    qt.Name = "TEQuery"
    qt.Refresh <-- error thrown on this line

When I call refresh, I get 1004: Application-defined or object-defined error, which seems too generic of an error for me to figure out what might be the issue. 当我打电话给刷新时,我得到1004:应用程序定义的错误或对象定义的错误,对于我来说,这似乎太笼统了,无法弄清问题所在。

In the locals window I can see that the qt and activesheet.querytables objects are behaving as I expect (non-null etc.), and I've checked my query text definitely returns a sensible result when run at the data source. 在locals窗口中,我可以看到qt和activesheet.querytables对象的行为符合我的预期(非null等),并且我检查了我的查询文本在数据源上运行时肯定返回了合理的结果。 Any ideas? 有任何想法吗?

ETA - I've noticed that Oracle Provider for OLE DB is missing from the data connections wizard - this is a new oracle client 11.2.0 install - got a new machine since I last used this macro...could this be the problem? ETA-我注意到数据连接向导中缺少OLE DB的Oracle Provider-这是一个新的oracle客户端11.2.0安装-自从我上次使用此宏以来,有了一台新机器...这可能是问题吗?

Glad to be answering my own question for once :) 很高兴能一次回答我自己的问题:)

I had the 64-bit client installed, so excel 2007 obviously couldn't connect, as it's a 32-bit application and required the 32-bit client drivers. 我安装了64位客户端,因此excel 2007显然无法连接,因为它是32位应用程序,需要32位客户端驱动程序。

Still - shame about the generic error message! 仍然-对通用错误消息感到羞耻!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM