Stop userform being dragged to one side

  • Thread starter Thread starter Kennyatwork
  • Start date Start date
K

Kennyatwork

Hello everyone

Is it possible to lock a userform so It cannot be dragged about?
I have a userform which opens in the middle of the screen covering some
data. I do not want the user to be able to see this data by dragging the
form out of the way!

any ideas?

Kenny
 
Hi Kenny,

Would it not make more sense to hide the data? Maybe display a blank
worksheet whilst the userform is open.

If you really want to lock the userform then try adding the following to
a userform code module. Watch the line wrapping.

Private m_blnActivated As Boolean
Private m_sngLeft As Single
Private m_sngTop As Single
Private Sub UserForm_Activate()
m_blnActivated = True
m_sngLeft = Me.Left
m_sngTop = Me.Top
End Sub
Private Sub UserForm_Layout()
If m_blnActivated Then Me.Move m_sngLeft, m_sngTop
End Sub
Private Sub UserForm_MouseUp(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
Me.Move m_sngLeft, m_sngTop
End Sub

Cheers
Andy
 
Back
Top