擅长:python、mysql、java
<p>看来你的错误在这一行:</p>
<pre><code>qt = ws.QueryTables.Add(rs, ws.Range["A1"])
</code></pre>
<p>你认为你的python语法是一个使用vbi的问题。试着把你的方括号改成圆括号。在</p>
<p>即</p>
^{pr2}$
<p>原因是在VBA中,当您调用这样的集合时,<code>Range("A1")</code>,实际上是在调用它的默认方法<code>Range.Item("A1")</code>。基本上,VBA集合不能转换成python字典。在</p>
<p>我从这个<a href="http://mail.python.org/pipermail/python-list/2001-December/116793.html" rel="nofollow noreferrer">forum thread</a>和我的VBA经验中得到了这个。在</p>
<hr/>
<p>因评论而编辑:</p>
<blockquote>
<p>Unfortunately, I've tried both: as
noted in your link, they sometimes
don't do the same thing, but my gut
feeling here is that the '[' is more
likely to be what I want. – mavnn</p>
</blockquote>
<p>你知道<code>comtypes.client.CreateObject</code>和{<cd4>}是否相同?您可以尝试用win32com包创建com对象,看看这是否有什么不同。在</p>