微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为什么在运行以下宏时会打开“数据链路属性框”?

如何解决为什么在运行以下宏时会打开“数据链路属性框”?

下面的宏代码运行了几年没有错误,但现在打开“数据链接属性”窗口时打开文件夹中的文件,按照下面代码的最后一行。无论我们做什么,代码都会在下面的最后一行失败。任何文件中都没有数据链接或外部连接,现在所有文件似乎都会发生这种情况(甚至打开空白文件)。这个问题大约在两个月前发生在 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)

This is the window that appears and nothing we do gets us past this window without error

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。