Consulting

Results 1 to 2 of 2

Thread: run msgox at certain times of the day only if a specific workbook is still open

  1. #1
    VBAX Regular
    Joined
    Jan 2015
    Posts
    42
    Location

    run msgox at certain times of the day only if a specific workbook is still open

    Is there a way via vba to automate a popup message box when certain times of the day is reached, with being to task heavy, lets say having a macro check systems time every 15minutes or so, using a call to wait a while , like sleep

    thanks in advance for any advice

        Calculate
        Sleep (150000) ' delay 
    
    or application.Wait(Now + TimeValue("00:00:01"))


    Option Explicit
    
    Sub ScheduleNext()
        'Schedules the macro to run again in one hour
    
        If TimeValue(Now) = TimeValue("03:40:00 AM") Then
         Application.OnTime TimeValue("03:40:00 AM"), "msgboxA"
        ElseIf TimeValue(Now) < TimeValue("03:40:00 AM") Then
            Application.OnTime Now + TimeValue("03:42:00 AM"), "msgboxb"
            ' do nothing
        End If
    End Sub
    
    Sub msgboxA()
    msgbox " Time for to do something"
    End Sub
    Sub msgboxb()
    msgbox " No Time to do something"
    End Sub

  2. #2
    VBAX Expert Logit's Avatar
    Joined
    Sep 2016
    Posts
    606
    Location
    .
    Paste this into a routine module:


    Option Explicit
    
    
    Sub shwMsg()
        Application.OnTime Now + TimeValue("00:00:20"), "shwMsg"    '<--- Set for 20 Seconds.  15 minutes would be "00:15:00"
        MsgBox "This is your message !"
    End Sub
    Activate it with a CommandButton.

Posting Permissions

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