Lock a userform in place


Posted by Josh on January 15, 2002 8:54 PM

Is there any way to lock a userform in its place so that the user cannot move it around?

Thanks
Josh



Posted by Mike on January 16, 2002 5:57 AM

Here is one way. It could probably be done better with the WIN32 API. Add 2 global variable myTop and myLeft and declare them as LONG. Then add this code:

Private Sub UserForm_Activate()

myTop = UserForm1.Top
myLeft = UserForm1.Left

End Sub

Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)

If UserForm1.Top <> myTop Then UserForm1.Top = myTop
If UserForm1.Left <> myLeft Then UserForm1.Left = myLeft

End Sub

-Mike