excel - 为什么在运行以下宏时会打开“数据链路属性框”?
问题描述
下面的宏代码工作了几年而没有错误,但现在在按照下面代码的最后一行打开文件夹中的文件时会打开“数据链接属性”窗口。无论我们做什么,代码都会在下面的最后一行失败。任何文件中都没有数据链接或外部连接,现在似乎所有文件都会发生这种情况(甚至打开空白文件)。这个问题在 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)
解决方案
推荐阅读
- reactjs - React 应用程序视频挂起,浏览器显示许多“待处理”流
- sql - 按日期、名称和值的 PIVOT SQL 表
- c# - 进度条超过最大值
- java - 当我发布的数量超过获取数量时,Java 信号量会增加许可数量
- vba - 未为 SaveAs 设置对象变量或 With 块 - vba
- javascript - 将值从对象传输到数组 - Javascript
- c++ - 如何使自定义小部件内的子小部件的信号可连接?
- python - sqlalchemy删除功能问题,我想删除单个项目,但它实际上删除了整个类别?
- angular - 如何在角度 2 及以上的点击事件后切换 li 上的类
- entity-framework - EF Core:更新数据时防止个别查询