I can resize the form, but how do I recenter the form on the screen once I do so?
Thanks.
-Git
Printable View
I can resize the form, but how do I recenter the form on the screen once I do so?
Thanks.
-Git
' Centres a form either on the screen (default) or over another form
Public Sub CentreForm(Optional varMoveForm As Variant, Optional varRefForm As Variant)
Dim frmMoveForm As Form
If IsMissing(varMoveForm) Or Not TypeOf varMoveForm Is Form Then
Set frmMoveForm = Screen.ActiveForm
Else
Set frmMoveForm = varMoveForm
End If
With frmMoveForm
If IsMissing(varRefForm) Or TypeOf varRefForm Is Screen Then
.Move (Screen.Width - .Width) / 2, (Screen.Height - .Height) / 2
ElseIf TypeOf varRefForm Is Form Then
.Move varRefForm.Left + (varRefForm.Width - .Width) / 2, varRefForm.Top + (varRefForm.Height - .Height) / 2
End If
End With
End Sub