My guess is that this is somehow related to MS Internet Explorer (full article here). In your question you don't specify anything about how or from where you're calling your macro, so I can't be sure. However, I've seen instances like this where the code is referring to the MSIE Application
object and not the Excel one. Even if it's not MSIE, it could still be another object that has its own Application
defined so it conflicts with Excel's Application
object, so the following should still apply.
If I'm right, then you need to add the following line of code to your macro before the line of code that changes the DisplayAlerts
property:
On Error Resume Next
You can also add the following line of code after the line of code that changes the DisplayAlerts
property:
On Error GoTo 0
So basically, something like this:
On Error Resume Next 'This line is required.
Application.DisplayAlerts = False
On Error GoTo 0 'This line is optional to revert the error handling to default behaviour.
By adding these lines of code to your macro, you suppress the error message and the macro continues to run. Note that you cannot change the DisplayAlerts
property in this case.