+ Reply to Thread
Results 1 to 7 of 7

MsgBox with Timer

  1. #1
    CarlosAntenna
    Guest

    MsgBox with Timer

    Is it possible to display a MsgBox for 5 seconds and then make it disappear
    without clicking the OK button? I looked at help under MsgBox but did not
    see such an option. Is there some other way to achieve the same result?

    --Carlos



  2. #2
    Chip Pearson
    Guest

    Re: MsgBox with Timer

    Carlos,

    In VBA, go to the Tools menu, choose References, and scroll down
    to "Windows Script Host Object Model". Check this item in the
    list. Then, use code like

    Dim SH As IWshRuntimeLibrary.WshShell
    Dim Res As Long
    Set SH = New IWshRuntimeLibrary.WshShell
    Res = SH.Popup(Text:="Click Me", secondstowait:=5, _
    Title:="Hello, World", Type:=vbOKOnly)


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com




    "CarlosAntenna" <[email protected]> wrote in message
    news:[email protected]...
    > Is it possible to display a MsgBox for 5 seconds and then make
    > it disappear
    > without clicking the OK button? I looked at help under MsgBox
    > but did not
    > see such an option. Is there some other way to achieve the
    > same result?
    >
    > --Carlos
    >
    >




  3. #3
    bigwheel
    Guest

    RE: MsgBox with Timer

    You could make your msgbox with a user form and have the form run the
    following when it activates

    Private Sub UserForm_Activate()

    Application.OnTime Now + TimeValue("00:00:10"), "CloseForm"

    End Sub

    The "CloseForm" is a macro which closes the user form :-

    Public Sub CloseForm()
    Unload userform1
    End Sub


    "CarlosAntenna" wrote:

    > Is it possible to display a MsgBox for 5 seconds and then make it disappear
    > without clicking the OK button? I looked at help under MsgBox but did not
    > see such an option. Is there some other way to achieve the same result?
    >
    > --Carlos
    >
    >
    >


  4. #4
    CarlosAntenna
    Guest

    Re: MsgBox with Timer

    Chip, You're a genius.
    It works like a charm. You even included the OK button for users who are
    too impatient to wait 5 seconds.
    Thanks for the rapid response.

    -- Carlos

    "Chip Pearson" <[email protected]> wrote in message
    news:[email protected]...
    > Carlos,
    >
    > In VBA, go to the Tools menu, choose References, and scroll down
    > to "Windows Script Host Object Model". Check this item in the
    > list. Then, use code like
    >
    > Dim SH As IWshRuntimeLibrary.WshShell
    > Dim Res As Long
    > Set SH = New IWshRuntimeLibrary.WshShell
    > Res = SH.Popup(Text:="Click Me", secondstowait:=5, _
    > Title:="Hello, World", Type:=vbOKOnly)
    >
    >
    > --
    > Cordially,
    > Chip Pearson
    > Microsoft MVP - Excel
    > Pearson Software Consulting, LLC
    > www.cpearson.com
    >
    >
    >
    >
    > "CarlosAntenna" <[email protected]> wrote in message
    > news:[email protected]...
    > > Is it possible to display a MsgBox for 5 seconds and then make
    > > it disappear
    > > without clicking the OK button? I looked at help under MsgBox
    > > but did not
    > > see such an option. Is there some other way to achieve the
    > > same result?
    > >
    > > --Carlos
    > >
    > >

    >
    >




  5. #5
    CarlosAntenna
    Guest

    Re: MsgBox with Timer

    Thanks Big. I have not tried your solution because I already got it working
    with Chip's method. Yours looks like exactly the kind of work-around I was
    looking for.

    Thanks,
    --Carlos

    "bigwheel" <[email protected]> wrote in message
    news:[email protected]...
    > You could make your msgbox with a user form and have the form run the
    > following when it activates
    >
    > Private Sub UserForm_Activate()
    >
    > Application.OnTime Now + TimeValue("00:00:10"), "CloseForm"
    >
    > End Sub
    >
    > The "CloseForm" is a macro which closes the user form :-
    >
    > Public Sub CloseForm()
    > Unload userform1
    > End Sub
    >
    >
    > "CarlosAntenna" wrote:
    >
    > > Is it possible to display a MsgBox for 5 seconds and then make it

    disappear
    > > without clicking the OK button? I looked at help under MsgBox but did

    not
    > > see such an option. Is there some other way to achieve the same result?
    > >
    > > --Carlos
    > >
    > >
    > >




  6. #6
    Registered User
    Join Date
    09-16-2020
    Location
    Buenos Aires, Argentina
    MS-Off Ver
    2019
    Posts
    1

    Re: MsgBox with Timer

    How can I set it to less than 1 second?

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: MsgBox with Timer

    Quote Originally Posted by soymatifer View Post
    How can I set it to less than 1 second?
    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ 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