• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Message Box Always on Top

dparteka

Member
Below is a line of code, when executed the message box does not appear on top of other windows that are open. Does anyone know if it's possible for this message box to always pop-up on top of all other opened windows? Thank you for looking, any help will be greatly appreciated.

Code:
MsgBox "My Message Here", vbCritical, "IRR Log Monitor"
 
Last edited by a moderator:
Vletm... thanks but all that does is cause the app button in the task bar to flash just like these others
Code:
AppActivate Application.Caption
Application.Workbooks(ThisWorkbook.Name).Activate
ThisWorkbook.Activate
Application.WindowState = xlNormal
AppActivate "Microsoft Excel"
 
dparteka
You asked something about 'Message Box Always On Top' or how?
Did You start a new case or what?
You even missed Your Message Box ... hmm?
 
Logit... thank you for your input, just like the other examples I listed above including the "+ vbSystemModal" only causes the app button in the task bar to flash, it does not bring the message box on top of all other opened windows.

vletm... no new case, yes I'm still trying to get my message box to appear in front of all other opened windows. The 5 lines of code I included in my last response are what I've tried, they all respond the same way with the app button in the task bar flashing, they do not bring the message box in front of all other windows.

I'm using Window-7 and OfficePro-2010, maybe that has something to do with it. The main goal here is to immediately notify the user of the message, this won't happen when the message is displayed under several other windows. Another idea I had was to have an annoying sound play until the user responds to the message box, any ideas on that approach?
 
dparteka
1) That works with my Excel. I even tested that.
2) If You ask 'something' and You mean 'something' else
then It would be challenge for You!
...as same as, if You send 'one line of code',
but 'some other lines of code' would change the whole Your case.
> Ideas: Send used code...
 
Hope this helps, thanks again for looking

Below is in ThisWorkbook module
Code:
Option Explicit

Private Sub Workbook_BeforeClose(Cancel As Boolean)
    StopTimer
End Sub

Private Sub Workbook_Open()
    StartTimer
End Sub

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    StopTimer
    StartTimer
End Sub

Below is in Module1
Code:
Option Explicit

Public RunWhen As Double
Public Const cRunIntervalSeconds = 1260 '21 minutes(21*60)
Public Const cRunWhat = "TheSub"  'the name of the procedure to run

Sub StartTimer()
    RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
    Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, _
        Schedule:=True
End Sub

Sub TheSub()
Application.Workbooks(ThisWorkbook.Name).Activate
MsgBox "The IRR log has been idle for over 20 minutes " & vbCrLf & _
        "If you are not actively using the log then please exit", _
         vbExclamation, "IRR Log Monitor"
    StartTimer  'Reschedule the procedure
End Sub

Sub StopTimer()
    On Error Resume Next
    Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, _
        Schedule:=False
End Sub
 
This works here, as expected. There must be something wrong with your
installation of Excel or perhaps a Windows update has created an issue with Excel.

Code:
Option Explicit

Public RunWhen As Double
Public Const cRunIntervalSeconds = 10 '21 minutes(21*60)
Public Const cRunWhat = "TheSub"  'the name of the procedure to run

Sub StartTimer()
    RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
    Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, _
        Schedule:=True
End Sub

Sub TheSub()
Application.Workbooks(ThisWorkbook.Name).Activate
'MsgBox "The IRR log has been idle for over 20 minutes " & vbCrLf & _
'        "If you are not actively using the log then please exit", _
'        vbExclamation, "IRR Log Monitor"
MsgBox "Hello, World!", vbCritical + vbSystemModal
    StartTimer  'Reschedule the procedure
End Sub

Sub StopTimer()
    On Error Resume Next
    Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, _
        Schedule:=False
End Sub
 
Dear @dparteka
So you are mixing the two threads in between which should to avoid. Indeed my lastest upload was also working as desired here too.
Changes made by you should also to work if you focused on depth irrespective of just copy paste.
 
Last edited:
This works here, as expected. There must be something wrong with your
installation of Excel or perhaps a Windows update has created an issue with Excel.
Nothing wrong with the installation barring the correct copy paste as vbsystem modal
 
I am confused at this point ... are we answering questions for dparteka or Deepak ?

Deepak .. you seem to be responding for dparteka. Are you one in the same ?

Posts #10, #11, #12.
 
Back
Top