简体   繁体   English

Excel Web查询中的参数

[英]Parameters in a Excel Web Query

I'm trying to import data from the web and it works fine for a static URL. 我正在尝试从网络上导入数据,它对于静态URL可以正常工作。 The URL looks something like this: http://www.foo.com/api/v0.9/csv/items/3/1 The last number (here "1") controls the page count. URL看起来像这样: http : //www.foo.com/api/v0.9/csv/items/3/1最后一个数字(此处为“ 1”)控制页数。 As there is about 200 pages in total I'd rather not remake 200 static queries, so my question is how can I parametrize this? 由于总共约有200页,所以我不想重做200个静态查询,所以我的问题是如何对它进行参数化?

I've searched the internet and the only solution I found it changing the URL in something like http://www.foo.com/api/v0.9/json/items/3.html?page=1 But my URL just works differently so the solutions don't apply. 我已经搜索了互联网,并且找到了唯一的解决方案,它找到了更改URL的方法,例如http://www.foo.com/api/v0.9/json/items/3.html?page=1,但是我的URL只是工作原理不同,因此解决方案不适用。

Can anyone tell me how it can be parametrized in my case or point me in the right direction? 谁能告诉我在我的情况下如何对它进行参数化或为我指明正确的方向?

Thank you for your time 感谢您的时间

You can change QueryTable.Connection property to point to a different URL. 您可以更改QueryTable.Connection属性以指向其他URL。 Here's an example 这是一个例子

Dim i As Long
Dim qt As QueryTable

For i = 1 To 200
    Set qt = Sheet1.QueryTables(1)
    qt.Connection = "URL;http://www.foo.com/api/v0.9/csv/" & i
    qt.Refresh False


    'Do some stuff with the data
Next i

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

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