I have the following code which centers user forms on their screen, i have this in every module (with a different form name of course), but would like to simlyfy it into a global module and just call it from each form when it initialises.
Private Sub UserForm_Initialize()
With frm_About
.StartUpPosition = 0
.Left = Application.Left + (0.5 * Application.Width) - (0.5 * .Width)
.Top = Application.Top + (0.5 * Application.Height) - (0.5 * .Height)
.Show
End With
End Sub
I was thinking something along the lines of storing the form name as a varaible (strFrmName) and then using code as such :
PrFunstion Center_UserForm()
With strFrmName
.StartUpPosition = 0
.Left = Application.Left + (0.5 * Application.Width) - (0.5 * .Width)
.Top = Application.Top + (0.5 * Application.Height) - (0.5 * .Height)
.Show
End With
End Sub
But its not working. I have also tried the below with no luck. Icannot find anythin online about this either:
With vba.userforms(strFrmName)
Bookmarks