J
Jonathan Brown
I have a userform that I've added to a spreadsheet that I've been using. It's
being used as a floating form. It can be moved anywhere on the form as the
user interacts with the spreadsheet. What I'd like to do is save the screen
position (top and left properties) when I close the form. So that the next
time the user opens the form it'll move back to the position it was in last
time.
So what I've done is I've coded the userform terminate event to write the
top and left properties to a sheet in the workbook. next time the form opens
it'll read those cells and move the form to the position saved.
Here's what I've got:
Private Sub UserForm_Terminate()
Sheets("Manning Config").Range("BU3").Value = Me.Left
Sheets("Manning Config").Range("BV3").Value = Me.Top
End Sub
The problem though is that it's writing zeros to the cells and not the
actual screen position where the form is sitting. Is the Me.Left and Me.Top
properties not the ones that I should be reading from?
Also, I haven't yet coded the form activate event yet. I'll have to have
some condition that will get the screen width and height and make sure that
the saved top and left values aren't larger than the available screen space
so that it doesn't try to open the form in a place where the user can't get
it. I think I already know how to do this part though.
being used as a floating form. It can be moved anywhere on the form as the
user interacts with the spreadsheet. What I'd like to do is save the screen
position (top and left properties) when I close the form. So that the next
time the user opens the form it'll move back to the position it was in last
time.
So what I've done is I've coded the userform terminate event to write the
top and left properties to a sheet in the workbook. next time the form opens
it'll read those cells and move the form to the position saved.
Here's what I've got:
Private Sub UserForm_Terminate()
Sheets("Manning Config").Range("BU3").Value = Me.Left
Sheets("Manning Config").Range("BV3").Value = Me.Top
End Sub
The problem though is that it's writing zeros to the cells and not the
actual screen position where the form is sitting. Is the Me.Left and Me.Top
properties not the ones that I should be reading from?
Also, I haven't yet coded the form activate event yet. I'll have to have
some condition that will get the screen width and height and make sure that
the saved top and left values aren't larger than the available screen space
so that it doesn't try to open the form in a place where the user can't get
it. I think I already know how to do this part though.