Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Apr 2002
    Location
    Busselton, Western Australia, Australia
    Posts
    59
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Form Terminate Event (Excel 2000 SP3)

    When trying to terminate a form by using the "X" box in the upper right corner of the form I find that code relating to anything on the form is not successful.
    ie if the following code is used it wil not record the data.
    The top and left variables are global variables used elsewhere...

    Private Sub UserForm_Terminate()
    top_posn = Me.Top
    left_posn = Me.Left
    Unload Me
    End Sub

    This code does not record the position of the form prior to terminating the form.
    How do I record this information when closing the form?
    Looking forward to your help
    Regards
    Brian.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Form Terminate Event (Excel 2000 SP3)

    The problem is that the Terminate event occurs when the form has already been unloaded from memory, so the Top and Left properties have been reset to 0. (The line Unload Me is superfluous).
    You can user the QueryClose event to retrieve information before the form is unloaded:

    Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    ...

  3. #3
    Star Lounger
    Join Date
    Apr 2002
    Location
    Busselton, Western Australia, Australia
    Posts
    59
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Re: Form Terminate Event (Excel 2000 SP3)

    Thanks Heaps Hans,
    This worked a treat!
    Regards
    Brian.

Posting Permissions

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