Requirement:
The user is a teacher using zoom.us to deliver online lessons. The user uses excel VBA to provide content to paste into the chat function of zoom. Zoom, Powerpoint and Excel are open at the same time, and the user uses alt Tab to move between windows.
I am trying to add a timer to the excel vba program. The timer works great but the user needs the userform message box to open above the zoom window when the time has elapsed. At the present all that happens is that the excel icon in the task bar flashes red.
Private Sub Timer_cmdBtn_Click() Dim startTime As Long startTime = CLng(Timer()) Do Loop While ElapsedTime(startTime) < 4 MsgBox ("Times up") 'This message should appear above all other windows End Sub Public Function ElapsedTime(ByVal startTime As Long) As Long ElapsedTime = CLng(Timer() - startTime) End Function
Solution:
Option Explicit Private Declare Function myMessageBox Lib "User32" Alias "MessageBoxA" _ (ByVal hWnd As Long, _ ByVal lpText As String, _ ByVal lpCaption As String, _ ByVal wType As Long) As Long Sub mytest() myMessageBox &O0, "MyMessageBox is on top of all windows", "MyMessageBox Caption", vbSystemModal End Sub
Obtained from the OzGrid Help Forum.
Solution provided by pike.
See also: Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions and Index to new resources and reference sheets
See also:
How to calculate userform textbox and cell value for label caption |
How to vertically centre text in userform label |
How to clear Userform |
How to print userform in orientation landscape |
How to use Excel VBA userform list box |
Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.