Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Jul 2001
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    fixing userform position (Any)

    Is there a way to fix the position of a userform so that it cannot move but still be used. If not then how would you code it so that if the user moved the form then it would go back to the center of the screen by itself?

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: fixing userform position (Any)

    I have not been able to find any event which fires when you move a user form, and there is no property to prevent it from being moved. About the only suggestion I would have would be to use the OnTime method to run a VBA routine every .5 seconds or so while the form is displayed. That routine would check to see if the form had been moved, and if it was move it back where you want it.
    Legare Coleman

  3. #3
    2 Star Lounger
    Join Date
    Jul 2001
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: fixing userform position (Any)

    okay but how do I do that, the on time method I mean

  4. #4
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: fixing userform position (Any)

    The following should replace the Userform the userform to the startup poition, if it is moved. (Excel 2000, I don't think it will work with XL97)

    Private Sub UserForm_Layout()
    Me.Hide
    Me.Show
    End Sub

    I have not tried with too many controls, so you might experiment with your actual form.

    I think to disable any movement of the form would require API calls, and possibly the removal of the caption bar.

    Andrew C

  5. #5
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: fixing userform position (Any)

    Andrew: You are correct. The Layout event does not trigger when the form is moved in 97. I could not find any event that triggered in 97.
    Legare Coleman

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •