+ Reply to Thread
Results 1 to 19 of 19

Cant get MSGBOX to disappear after clicking on the OK button.

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Cant get MSGBOX to disappear after clicking on the OK button.

    Hi,

    I have an application in excel vba where i show the user a msgbox. However, when the user clicks ok the msgbox stays on the screen. Any ideas how to get it to disappear?

  2. #2
    Valued Forum Contributor
    Join Date
    05-07-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    354

    Re: Cant get MSGBOX to disappear after clicking on the OK button.

    I think it will be helpful if you shared the code that shows the message box as well as code that handles the vbok response...
    Regards,
    Vandan

  3. #3
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Cant get MSGBOX to disappear after clicking on the OK button.

    code is shown below



    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor
    Join Date
    05-07-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    354

    Re: Cant get MSGBOX to disappear after clicking on the OK button.

    I don't see anything wrong with your msgbox command.

    If you Debug-> Step into (F8) through your code, I bet you will find that the message box appears because the next file is also bad file...

  5. #5
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Cant get MSGBOX to disappear after clicking on the OK button.

    there is only a single bad file.......i know cause i created the test and i know there is only a single bad file.

    i have readon some posts that if following a msgbox there is "intense" code (not sure what this means) that sometimes the msgbox will stay on the screen.........


    to be honest i am at a loss......the msgbox stays on the screen until the program stops running or until another msgbox is displayed. i thought it might have something to do with screen updating so this is why i turned it on before showing the msgbox...........at a loss..........any ideas?

  6. #6
    Valued Forum Contributor
    Join Date
    05-07-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    354

    Re: Cant get MSGBOX to disappear after clicking on the OK button.

    Is it possible for you to upload the file? This will make troubleshooting easier.

    If not, have you tried stepping through the code using F8? That might help you pinpoint the problem.

  7. #7
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Cant get MSGBOX to disappear after clicking on the OK button.

    no the code is part of a larger program.....cant load it up......but i will try the stepping through.....

    any other ideas?

  8. #8
    Valued Forum Contributor
    Join Date
    05-07-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    354

    Re: Cant get MSGBOX to disappear after clicking on the OK button.

    Let's see what stepping through the code tells us...if that isn't useful let me know and I will call on others to help.

  9. #9
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Cant get MSGBOX to disappear after clicking on the OK button.

    as best i can tell the msgbox went away but not sure. i ran it twice the first time i ran it where the vba code showed on my screen the msgbox came up i hit ok and then pressed F8 and it went away....

    the 2nd time i ran it where the spreadsheet was visible and this kinda did nto workl.........i could not step through it.

    so not sure the result.

  10. #10
    Valued Forum Contributor
    Join Date
    05-07-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    354

    Re: Cant get MSGBOX to disappear after clicking on the OK button.

    I have asked others to look at this issue. Hopefully somebody can help you solve this for good.

  11. #11
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Cant get MSGBOX to disappear after clicking on the OK button.

    Try this and see if this works:

    Please Login or Register  to view this content.
    sometimes I have found that the system need a second to wake up
    Last edited by abousetta; 07-10-2012 at 09:17 PM.
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  12. #12
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Cant get MSGBOX to disappear after clicking on the OK button.

    i got a type mismatch error when i tried the code you presented. but it did give me an idea.

    instead of putting the screenupdating prior to the msgbox i put it after it and IT WORKED!

    here is the code which

    Please Login or Register  to view this content.


    any ideas why this works?

  13. #13
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Cant get MSGBOX to disappear after clicking on the OK button.

    It should have been timevalue instead of time. I have changed it above.

    Glad it all worked out. If you are satisfied with the results then please mark the thread as solved.

    Also we have a competition this month on Excel Forum, please stop by and click on the like button of the tips you find of benefit.

    Good luck.

    abousetta

  14. #14
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: Cant get MSGBOX to disappear after clicking on the OK button.

    In the code module for "udpate_bad_file_array()", which you were calling after turning ScreenUpdating to True originally, is there a line setting it back to False?

    Also note that "update" is spelled incorrectly. Gotta be careful.

  15. #15
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Cant get MSGBOX to disappear after clicking on the OK button.

    Option explicit on the top of your code should catch a lot of these simple mistakes.

  16. #16
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: Cant get MSGBOX to disappear after clicking on the OK button.

    Technically it wouldn't catch that mistake as long as you named the actual routine in the same incorrect way.

  17. #17
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Cant get MSGBOX to disappear after clicking on the OK button.

    and I think that's the case in this situation since it compiled

  18. #18
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Cant get MSGBOX to disappear after clicking on the OK button.

    thanks for the info. i checked that other procedure and it did not have an assignment to turn off updating.......but that was a good idea to check. thanks.

    abousetta ,
    i tried out your code update and it does not create a runtime error thanks.


    guess i will never know why adding "screen updating" AFTER made the msgbox go away. do you think its just a timing issue?

  19. #19
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Cant get MSGBOX to disappear after clicking on the OK button.

    Screenupdating can be turned on and off while the code is running. It is all ways on before the sub runs and will all ways turn on again after the all subs finish even if you don't tell it to turn on again. If you want to debug it then step through your code from the top to bottom and see where you turn Screenupdating on and off.

    From experience I have noticed that sometimes with screenupdating off, message boxes, input boxes, etc. will appear on the screen even after the user click OK or Cancel.

    Hope this helps.

    abousetta

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1