Consulting

Results 1 to 10 of 10

Thread: How to automatically trigger a VBA code to respond to expected msgbox

  1. #1

    How to automatically trigger a VBA code to respond to expected msgbox

    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.

  2. #2
    VBAX Regular
    Joined
    Jun 2008
    Posts
    64
    Location
    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.

  3. #3
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    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.
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  4. #4
    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.

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,443
    Location
    Look at Senkeys in VBA help.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    What Senkeys stands for? No search results return.

  7. #7
    VBAX Regular
    Joined
    Jun 2008
    Posts
    64
    Location
    Sendkeys

  8. #8
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,443
    Location
    Quote Originally Posted by zcdy
    What Senkeys stands for? No search results return.
    Sorry, my bad, I meant SendKeys.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  9. #9
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    You can do this very easily with 3rd party automation software. Personally I would suggest vTask Studio. 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.
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


  10. #10
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •