Automatically run data connections in XLSM

∥☆過路亽.° 提交于 2019-12-25 09:19:15

问题


I have an XLSM file which contains 2 Web Query connection. When I go to "Connections" in the "Data" tab I am presented with the two connections I have.

For each of these I can edit some properties, one which says "Update every X minutes". I've set this to 1 minute and also ticked "Activate background update".

This, however, won't work as the web query connections aren't run anyway.

Ultimately what I need is to run these connections automatically once every hour. Preferably without any user interaction and without the document being open.

Is this possible?


回答1:


You can't refresh a connection without the file being open. You can run queries on opening the file or create a VBA routine that opens the file, then uses the RefreshAll and saves over the original file every hour.
You can use VBS too.
The final solution by OP:

I ended up making a little VBS script to handle the open, refresh, close. Then a batch script wrapper to handle running the VBS script and logging. Finally Windows Task Scheduler to run the batch script periodically.



来源:https://stackoverflow.com/questions/40398444/automatically-run-data-connections-in-xlsm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!