我有一个工作簿(不是特别复杂),它有开放代码,然后检查源文件的更新,更新它,然后加载一堆图像。它有一个用户表单,显示它正在更新,然后再次隐藏它。
当此工作簿打开时,尝试打开更多工作簿会导致新文件停留在“正在下载:filename.xlsx”,然后达到100%,但实际上从未打开过该文件。按下转义会停止下载,如果没有下载提示,进一步尝试打开仍然无法成功打开。一旦工作簿关闭,一切都恢复正常。
原因是什么?
编辑:来源
Private Sub Workbook_Open()
Call ActivateRefresh
End Sub
Public Sub ActivateRefresh()
If Sheets("Settings").Range("LastUpdate") < Date Then
Call AutomaticRefresh
End If
End Sub
Public Sub AutomaticRefresh()
If LCase(Range("Refresh")) = "no" Then Exit Sub
If Date > Range("AutoRefreshDate") Then Exit Sub
If Range("Dept") = "" Then Exit Sub
If ActiveWorkbook.Path = "the template path" Then Exit Sub
lastUpdate = Range("LastUpdate")
season = Range("Season")
filedate = FileDateTime("somenetworkpath " & season & " - Department " & Sheets("Settings").Range("Dept") & ".0.xlsx")
If filedate > lastUpdate Then
RefreshForm.Show (False)
Call ManualRefresh
Range("LastUpdate") = filedate
RefreshForm.Hide
End If
End Sub
Public Sub ManualRefresh()
Application.DisplayAlerts = False
Set cs = Sheets("Style Cards")
season = Range("Season")
Set nb = Workbooks.Open(somenetworkpath " & season & " - Department " & Sheets("Settings").Range("Dept") & ".0.xlsx")
Set ns = nb.Sheets(1)
ns.Cells.Copy
cs.PasteSpecial
nb.Close
Call TryAddAllPhotos ' tries to load the photos
Call AddROS ' add ros
Application.DisplayAlerts = True
End Sub
Sub AddROS()
On Error Resume Next
If Range("Setting_AddRos") = "No" Then Exit Sub
Set cb = ActiveWorkbook
Application.StatusBar = "Updating Style ROS"
Application.ScreenUpdating = False
Set cs = Sheets("Style Cards")
cs.Range("I:I").Copy
cs.Range("M:M").PasteSpecial xlPasteFormats
Set sb = Workbooks.Open("slightly other network path", , True)
Set ss = sb.Sheets(1)
cb.Activate
Application.Calculation = xlCalculationManual
UseNext = False
snip ... do lots of calcs ...
Application.Calculate
cs.Range("M:M").Copy
cs.Range("M:M").PasteSpecial Paste:=xlPasteValues
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
Application.DisplayAlerts = False
sb.Close False
Application.DisplayAlerts = True
Application.StatusBar = False
End Sub