我正在创建一个宏,它可以打开大量文件,刷新它们,然后保存并关闭。一切运行顺利,但其中 2 个文件在打开时会弹出一条消息,显示“文件在包含列表中运行 - 标题可能丢失”。这会暂停宏,直到按下“ok”。我以前使用过“Application.DisplayAlerts = False”,但它似乎在这里不起作用。我的代码如下:
Public Sub Refresh_All()
Dim filepathstr As String
Dim filename As String
Dim wbk As Workbook
filepathstr = Sheet1.Range("filepath").Value
For Each cell In Sheet1.Range("workbooks")
If Not cell.Value = "" Then
filename = cell.Value
Application.DisplayAlerts = False
Set wbk = Workbooks.Open(filepathstr & filename, False)
''''**REFRESH**''''''
SAPBexrefresh (True)
Application.DisplayAlerts = False
wbk.Save
wbk.Close False
Application.DisplayAlerts = True
End If
Next cell
MsgBox "The Macro has finished; BW Reports are refreshed."
End Sub
任何帮助将不胜感激!