I'm looking to automate a workflow of opening a Workbook, running a macro and closing a file
//Run a Macro//
ActiveWorkbook.Close
But the problem with this is that I can't edit anything if I want to edit something, as it automatically closes the workbook. So I want to pop-up a Yes/No Message Box asking if I want to close the file. If there is no response it should automatically close(Press Yes).
/*Run a Macro*/
Close:= MsgBox, "Do you want to Close the File?", vbYesNo
/*Wait for 5 seconds for Response. If no response, automatically click Yes.*/
If Close = vbYes Then
ActiveWorkbook.Close
Else
'Don't Close
End If
P.S: Please do let me know if there is any simpler way to this.
Edit #1:
Thank you for the link below. I did find the link provided below useful, but it doesn't not satisy below points
- it is not a Yes/No popup.
- it doesn't click the Yes or Ok after 5 seconds. It just unloads the popup I tried this method using
- Userforms too. Using the Application.OnTime Now + TimeValue("00:00:05"), "Test" function. But even that is not desirable. Even if I click no the userform still runs the "Test" Sub.