Skip to main content

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.

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.

 

Thanks,

Hemantha Pindra


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.


Thanks for your response @HemanthaPindra 😀


Reply