I have made a userform in Excel and saved it. Every now and then when I open up the editor, the form has been resized by itself. When I click in the bottom right corner of the form to resize it, it automatically pops back to the original intended size (see the GIF
below).
This also affects the forms at runtime. Is this a bug needed to be fixed by Microsoft, or is there some sort of auto-resizing setting that I can disable?
I do have this initialization code with the hardcoded intended size:
Private Sub UserForm_Initialize()
Me.Width = 402.6
Me.Height = 430.8
Me.StartUpPosition = 0
Me.Left = Application.Left + (0.5 * Application.Width) - (0.5 * Me.Width)
Me.Top = Application.Top + (0.5 * Application.Height) - (0.5 * Me.Height)
End Sub
Thanks to @braX for pointing me to the right direction. It seems to be a DPI awareness issue.
The solution for me was to check the Optimize for compatibility
option, and restart Excel.