Morning
I have 5 userforms and i have managed using API cells to bring my 1st form to the tomost position, but when i use this code on another form in the exact same way, it does not work :S
I am not sure whether i need to change some of the code for it to work on other forms?
Well any way here is my code.
This is put in a module
I put this at the top of my form code
and this is the activate form bit of my code
It works on only one of my forms what do i need to change to get it to work on my others?
Thanks very much in advance
L
I have 5 userforms and i have managed using API cells to bring my 1st form to the tomost position, but when i use this code on another form in the exact same way, it does not work :S
I am not sure whether i need to change some of the code for it to work on other forms?
Well any way here is my code.
This is put in a module
Code:
Sub XcelFiles_Click()
Application.VBE.MainWindow.Visible = True
End Sub
I put this at the top of my form code
Code:
'API Cells to put form as topmost position
Private Declare Function FindWindow _
Lib "user32" _
Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) _
As Long
Private Declare Function SetWindowPos Lib "user32" ( _
ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal cx As Long, _
ByVal cy As Long, _
ByVal wFlags As Long) _
As Long
'Constants for SetWindowPos
Private Const HWND_TOP = 0
Private Const HWND_BOTTOM = 1
Private Const HWND_NOTOPMOST = -2
Private Const HWND_TOPMOST = -1
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_NOCOPYBITS = &H100
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOOWNERZORDER = &H200
Private Const SWP_NOREDRAW = &H8
Private Const SWP_NOSIZE = &H1
Private Const SWP_SHOWWINDOW = &H40
Dim frmhdl As Long
and this is the activate form bit of my code
Code:
Private Sub UserForm_Activate()
'Sets form to topmost position
SetWindowPos , HWND_TOPMOST, 0, 0, 0, 0, _
SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
End Sub
It works on only one of my forms what do i need to change to get it to work on my others?
Thanks very much in advance
L