如何禁止更新链接警告? [英] How to suppress Update Links warning?
问题描述
我正在尝试编写一个打开许多Excel文件的脚本。我不断得到提示:
I'm trying to write a script that opens many Excel files. I keep getting the prompt:
This workbook contains links to other data sources.
我想保持此消息不出现,因此我的脚本可以自动完成所有工作簿没有我必须单击不要更新
为每一个。目前我正在使用以下内容:
I want to keep this message from appearing, so that my script can just automatically go through all the workbooks without me having to click Don't Update
for each one. Currently I'm using the following:
function getWorkbook(bkPath as string) as workbook
Application.EnableEvents=False
Application.DisplayAlerts=False
getWorkbook=Workbooks.Open(bkPath,updatelinks:=0,readonly:=false)
end function
但是,消息仍然出现。如何抑制它?
However, the message is still appearing. How can I suppress it?
编辑:似乎这个消息正在出现断开链接的工作簿;我没看到此工作簿包含一个或多个无法更新的链接
消息,因为我将设置 DisplayAlerts
假的工作簿链接到Windows服务器上的文件夹中的等效文件,因此当匹配文件从该文件夹中删除(作为我们的业务流程的一部分)时,链接中断。链接断开时可以抑制警告吗?
It appears that this message is coming up for workbooks that have broken links; I wasn't seeing the This workbook contains one or more links that cannot be updated
message because I'd set DisplayAlerts
to false. The workbooks are linked to equivalent files in a folder on our Windows server, so when the matching file is deleted from that folder (which happens as part of our business flow), the link breaks. Is it possible to suppress the warning when the link is broken?
此外,我使用Excel 2010。
Also, I'm using Excel 2010.
推荐答案
我找到了一个临时解决方案,至少让我处理这份工作。我写了一个短的AutoIt脚本,等待更新链接窗口出现,然后点击不要更新按钮。代码如下:
I've found a temporary solution that will at least let me process this job. I wrote a short AutoIt script that waits for the "Update Links" window to appear, then clicks the "Don't Update" button. Code is as follows:
while 1
if winexists("Microsoft Excel","This workbook contains links to other data sources.") Then
controlclick("Microsoft Excel","This workbook contains links to other data sources.",2)
EndIf
WEnd
到目前为止,这似乎正在工作。我真的很想找到一个完全是VBA的解决方案,所以我可以使这个独立的应用程序。
So far this seems to be working. I'd really like to find a solution that's entirely VBA, however, so that I can make this a standalone application.
这篇关于如何禁止更新链接警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!