Reputation: 93
I'm creating a macro which opens numerous files, refreshes them, and then saves and closes. All is running smoothly however for 2 of the files when they are opened a message pops up which reads "Files run on an inclusion list - titles may be missing." this halts the macro until "ok" is pressed. I have used "Application.DisplayAlerts = False" before but it doesn't seem to be working here. My code is as follows:
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
Any help would be greatly appreciated!
Upvotes: 1
Views: 7953
Reputation: 2956
Add
Application.EnableEvents=False
before opening the wb and set back to true afterwards
Alternatively, use:
Application.AutomationSecurity=msoAutomationSecurityForceDisable
Remember to set back to whatever the user has...
Upvotes: 3