View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Leith Ross[_410_] Leith Ross[_410_] is offline
external usenet poster
 
Posts: 1
Default Show a Excel UserForm in Access


Hello Mark,

This code will keep your UserForm on top of all other forms. Add a VB
Module to your project and copy the code below into it.

CALLING THE MACRO
In the UserForm Activate event code module insert the following...
KeepFormOnTop


Code
-------------------

Private Declare Function SetWindowPos _
Lib "user32.dll" _
(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

'Returns the Window Handle of the Active Window
Public Declare Function GetActiveWindow _
Lib "user32.dll" () As Long

Public Sub KeepFormOnTop()

Dim hWnd As Long

Const HWND_NOTOPMOST = -2
Const HWND_TOPMOST = -1
Const SWP_NOMOVE = &H2
Const SWP_NOSIZE = &H1

hWnd = GetActiveWindow()

SetWindowPos hWnd, HWND_TOPMOST, 0, 0, 0, 0, _
SWP_NOMOVE + SWP_NOSIZE

End Sub

-------------------


Sincerely,
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=49561