Click "ok" on a vba msg box in excel with macro?


How to click ok, on vba msg box, using macro, like when excuting a macro function, it shows a msg box, is there a way to click ok on that msg box, using macro, so that the robot has no need to click on it, since it breaks down each time…

Thank you all

What message box is this?Does Macro is generating it?


Yes, the macro generate it, after excuting a funtion, saying that the work has been done correctly.

So i get a msg box with an ok button, that i have to click on, the thing is that i did excute first fuction excute, with macro on uipath, but it won’t move on, it gets stuck there, it doesn’t click on the button or do anything else, like it’s stuck. So i tough about using same thing for the click button and see if it works that way and also, i want have to change the selector each time i change the computer.

Sub Click_ExecuteAll()
Dim start As Long, bErr As Boolean
start = GetTickCount
bErr = testRefresh()
If bErr Then
Call ExportTableToCSV(“TEST”)
Call ExcelReport_Arr(“TEST”)
MsgBox "Execution time : " & Time2String(GetTickCount - start), vbInformation, “Execute all process”
End If
End Sub

PS : i don’t know how to code on vba or powerquery, somebody else did this…

Is it compulsory to have a message box in the Macro?If not remove the message box code in the VBA.


Please try Parallel activity in the UiPath and ask the uipath to click on okay

Yes, i can’t remove the msg box, i did try Parallel, i doesn’t work, i want to find a way without cliking on the button.

I have done simple Messgebot VBA and try to click it via UiPath can you trythis code?

Change the location of the excel as per your machine (13.9 KB)

1 Like


Still the same issue, the thing the selector sometimes changes, just on the excute function i have like 4 deffrents msg box, do you have any idea? that’s why i was looking for something lik macro to click on the button.


I tried to use attach window , and click ok Button inside the same . Can change the Title or Ctrl id .

@Priyanka_Ramesh @MuralidharVankamaddi

Doesn’t work correctly, now i get error that the message box ain’t here, can’t click ok, because the excel file hasn’t finish with the excute function… you sure there’s no other way than this?

Can you please cche the below link which will automatically dismiss Msgbox in VBA

1 Like


Thank you for the idea, i tried it doesn’t close…

can you share the Updated vba code

As I have tested it will take arount 15-20 seconds to close to make it close faster gice AckTime = 1 instead of 10

It’s the same as this :

CreateObject(“WScript.Shell”).Popup “Impossible de test” & vbCrLf & vbCrLf & “Veuillez vérifier test”, 5, “Test Refresh”

this is how I have done and it is working for me



Well ain’t working and i noticed that this is not the best way to do it, because i should get the error message for later purposes…

Anyway i make it as a solution and I thank you for your help. If you think of any other way please share.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.