首页 > 解决方案 > 为什么在运行以下宏时会打开“数据链路属性框”?

问题描述

下面的宏代码工作了几年而没有错误,但现在在按照下面代码的最后一行打开文件夹中的文件时会打开“数据链接属性”窗口。无论我们做什么,代码都会在下面的最后一行失败。任何文件中都没有数据链接或外部连接,现在似乎所有文件都会发生这种情况(甚至打开空白文件)。这个问题在 Excel 更新后大约两个月前发生,但大约两周后就消失了,但现在又回来了。我对 VBA 代码相当擅长,但我没有解释,我在网上也没有找到任何解释。

 Sub assetadjust()
        
    fiscalyearperiod = Application.InputBox("Type fiscal Year and period", "FYxxPxx")
    
        Application.ScreenUpdating = False
        Application.DisplayStatusBar = False
        Application.Calculation = xlCalculationManual
        Application.EnableEvents = False
        Application.PrintCommunication = False
        Application.DisplayAlerts = False
        Application.AskToUpdateLinks = False
    
        Dim thiswb, valwb, wb As Workbook
    
        Set valwb = ActiveWorkbook
        Set thiswb = ThisWorkbook
        Dim ws, ws2 As Worksheet
    
    If thiswb.Name = valwb.Name Then
    
        Dim FSO As Object
        Dim sFolder As String
        Dim ToPath As String
        Dim FileExt As String
        Dim path As String, count As Integer
         
    alias = Environ("UserName")
    FY = Left(fiscalyearperiod, 4)
    FP = Right(fiscalyearperiod, 3)
    
    
    sFolder = "C:\Users\" & Environ("UserName") & "\Desktop\To Run"
        
        FileExt = "*.xls*"
        Set FSO = CreateObject("scripting.filesystemobject")
        Set fold = FSO.GetFolder(sFolder)
        
    a = 2
        
    For Each file In fold.Files
        Application.Workbooks.Open (sFolder & "\" & file.Name)

这是出现的窗口,我们所做的任何事情都不会让我们通过这个窗口而不会出错

标签: excelvbahyperlinkproperties

解决方案


推荐阅读