Positioning

Create a new Userform and press F5 to display it.
The default position for the Userform should be in the center of the Office application.
When the user only has one monitor, this is fine.
However if the user has multiple screens you might find the Userform is not displayed in the center.
It really all depends how the screens are configured and which monitor is setup as the Primary screen.
Every Userform object has a property called StartUpPosition which can be used to change the default position.


StartUpPosition Property

0 - Manual - Allows you to use the Left and Top properties to specify an exact position.
1 - CenterOwner - (default) Not every time when you have multiple monitors. Only on your primary screen.
2 - CenterScreen - Not every time when you have multiple monitors. Only on your primary screen.
3 - WindowsDefault - Positions the userform in the top left corner of the screen.


StartUpPosition = Manual

There are a number of different approaches you can use to control the positioning of a userform.
The best approach is to calculate the exact Left and Top position and then pass this information to the userform in the Initialize event.
Before we calculate the Top and Left positions we need to change the StartUpPosition property of the userform to Manual (0).
It is worth emphasizing that this property must be changed at design-time and not at run-time.
Adding the following line of code in your Initialize event will not work.


Approach 1 - Application.UsableHeight

This approach uses the size of the application window.


Approach 2 - Saving the Position

This approach saves the position the userform was last in to the registry and then uses those values next time.


Approach 3 - Middle of Application Window / Current Screen

This approach uses several Windows APIs to make adjustments for the specific screen resolution.
This code snippet also includes the VBA7 Compiler Constant and the PtrSafe keyword.
Both of these were added in Office 2010 to allow compatibility with Office 64 bit.
Insert the following code into a regular code module.

Add the following code to your Userform module.


Approach 4 - Middle of All Screens

This approach uses the GetSystemMetrics Windows API.


Microsoft Access

If you are using Microsoft Access with pop-up Forms (as opposed to Userforms) the calculations are similar, but not quite identical.
You need to use twips instead of points.
There are 20 twips per point and you have to use the load event.


© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext