Run macro command - Pop-up problem

  • 27 June 2024
  • 3 replies

Badge +3

Hi everyone,

I have a question about excel advanced run macro command. I would appreciate it if someone who knows answer.

I am building a bot that will open an excel sheet, run a macro and close it again. But a pop-up appears while the macro is running.Since this pop-up is opened within the run macro command, the bot doesn’t move on to the next action. So capture or keystrokes actions don't work.

Is there another option I can do with AA?

* pop-up: "A file named already exists in this location. Do you want to replace it?"

Can I prevent this pop-up from appearing with a macro code?

Thanks in advance.


Best answer by HemanthaPindra 27 June 2024, 09:03

View original

3 replies

Userlevel 1
Badge +3

Hi @ufuksavas,


You have to use Application.DisplayAlerts property setting to False in your macro code. It will prevent Excel from displaying most dialog boxes and alerts.


Function FunctionName()

Application.DisplayAlerts = False

' Your code here

Application.DisplayAlerts = True ' Reset back to default

End Function


Hope it will help.



Hemantha Pindra

Userlevel 3
Badge +6

Thank you @HemanthaPindra, for the response. A good rule of thumb is to examine if the target application (Excel) can supress the pop-up displays, as it avoids the rather messy process of trying to automate unnamed windows, timing and focus issues, etc.

Badge +3

Thanks for your response @HemanthaPindra 😀