Hi Guys,
Brain has not initialised today.
After displaying an Excel (2003/XP) UserForm as Modal, how can I keep it within the Excel Application window? IE. It can't be moved outa the appliaction window....
Cheers,
Printable View
Hi Guys,
Brain has not initialised today.
After displaying an Excel (2003/XP) UserForm as Modal, how can I keep it within the Excel Application window? IE. It can't be moved outa the appliaction window....
Cheers,
Sup Bruce! :)
This is about as close as you can easily get. It still goes behind the command bars and over the task pane but its limited to the Excel application window.
VB Code:
Option Explicit Private Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Private Sub Workbook_Open() Dim lHwnd As Long UserForm1.Show vbModeless lHwnd = FindWindow("ThunderDFrame", "UserForm1") SetParent lHwnd, Application.Hwnd End Sub
Hey Rob,
Thanks for the reply.
I guessed that may be it, but thought I was overlooking the obvious ;)
Bruce.
Hmmm dosn't seem to work with Modal.....
Show the userform modaless to get its window handle. Then hide it and reshow it as modal. See if the handle remains the same. ;)
Showing it modally after its set as a child wont work after all as once its a child it becomes disabled due to the modality factor.
Trying a few other options aswell :)