PDA

View Full Version : How to automatically trigger a VBA code to respond to expected msgbox



zcdy
07-16-2008, 08:35 AM
Hi all,

I need to run a simulation of 5000 iterations. For each iteration, I would expect a msgbox event that requires manual response (click "Yes" or "No" button in the msgbox). I want the msgbox to trigger a VBA code which can automatically assign "Yes" or "No" to the msgbox and close it so as to continue into next iteration. How can I configure excel or VBA to link the VBA code to the msgbox event?

Many thanks.

mae0429
07-16-2008, 08:40 AM
Just to clarify: you want to be able to manually respond on the first iteration, and then save that response and input it to the msgbox each subsequent iteration?

Sounds possible. I'd have to think about it, though. I'm sure someone else knows right away.

Simon Lloyd
07-16-2008, 08:40 AM
You seriously want a message box to appear 5000 times and expect some poor souls to click them away? anyway you cannot clear a msgbox via code it is normally used to pause code!

What code do you want to run? why the yes no?, you would be better off with a userform.

zcdy
07-16-2008, 10:27 AM
The reason is I will run the simulation with third party software, and the response of Yes or No will depend on the average of certain outputs of previous iterations.

The VBA code will calculate the average of the outputs, and make a Yes or No selection in the msgbox.

Hope that clarify.

Bob Phillips
07-16-2008, 10:28 AM
Look at Senkeys in VBA help.

zcdy
07-16-2008, 10:47 AM
What Senkeys stands for? No search results return.

mae0429
07-16-2008, 10:49 AM
Sendkeys

Bob Phillips
07-16-2008, 10:51 AM
What Senkeys stands for? No search results return.

Sorry, my bad, I meant SendKeys.

CreganTur
07-16-2008, 12:25 PM
You can do this very easily with 3rd party automation software. Personally I would suggest vTask Studio (http://www.vista-software.com/index.php). I've been using it for about a year now, and it is amazing. A lot of people use it for software QA, among other things.

You do not have to learn any code to use it- it's pretty much drag and drop to assemble scripts out of the commands provided.

They've got a free trial of the full version of the software so you can test out its capabilities.

zcdy
07-16-2008, 08:37 PM
xld,

could you kindly provide the direction to related sendkey example? I tried googling several times and couldn't find any related examples.

CreqanTur,

I am using employee computer for this project. so it is not good to use any authorized third party software. but thanks for the advise.