Forms Display

  • Thread starter Thread starter ZAK
  • Start date Start date
Z

ZAK

Hi

I am displaying a warning form for a user when the cell
reaches a critical value. However I would like the form to
be at the forefront of all windows application, so that
the user has to acknowledge before he can resume to use
the computer. I am thinking in cases where the Excel is
minimised.

Regards

ZAK
 
Zak,

Try the following, for Excel 2000 and later.

Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Declare Function SetForegroundWindow Lib "user32" ( _
ByVal hwnd As Long) As Long

Sub ShowTheForm()
Dim FHwnd As Long
Load UserForm1
FHwnd = FindWindow("ThunderDFrame", UserForm1.Caption)
If FHwnd Then
SetForegroundWindow FHwnd
End If
UserForm1.Show
End Sub


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