VBA .ChangeLink问题

我正面临一个非常奇怪的VBA代码问题。 我有一个使用来自Addin的UDF的Excel文件。 这个文件运行在服务器上,所以我真的不可能看到代码中究竟发生了什么。 现在,无论何时在文件中(在本地机器上)进行任何更改,我都使用本地版本的外挂程序。 所以,当replace服务器上的文件时,我需要它自动更改链接到服务器上的插件副本。 为此,我在这个文件中有这段代码:

Private Sub changeLinks(addinName As String, wb As Workbook) Dim check As Long Dim i As Long Dim existingPath As String Dim correctPath As String Dim temp As Variant Dim tempA As Variant Application.DisplayAlerts = False Application.AskToUpdateLinks = False Application.ScreenUpdating = False temp = getLinks(addinName, wb) On Error Resume Next correctPath = Application.AddIns(addinName).fullName For i = 1 To 100 If temp(i) = "" Then Exit For If UCase(temp(i)) <> UCase(correctPath) Then wb.ChangeLink temp(i), correctPath, xlLinkTypeExcelLinks End If Next On Error GoTo 0 End Sub Private Function getLinks(addinName As String, wb As Workbook) Dim allLinks As Variant Dim check As Long Dim i As Long Dim temp(1 To 100) As Variant Dim linkCounts As Long check = 0 allLinks = wb.LinkSources linkCounts = 0 On Error Resume Next For i = LBound(allLinks) To UBound(allLinks) check = InStr(1, UCase(allLinks(i)), UCase(addinName)) If check <> 0 Then linkCounts = linkCounts + 1 temp(linkCounts) = allLinks(i) End If Next On Error GoTo 0 getLinks = temp End Function 

尽pipe所有的语句如Application.DisplayAlerts = False和On Error Resume Next,代码挂在我使用.ChangeLink方法的行上。 奇怪的是,如果我login到服务器并手动运行,代码工作正常。 我相信这是由于代码尝试运行时出现的一些popup窗口.ChangeLink语句。 我看不到popup窗口是什么,因为它使用不同的login名在服务器上运行。 所以现在我只是把我的头撞到墙上。

感谢任何帮助。