ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to control the UserForm's position? (https://www.excelbanter.com/excel-programming/333827-how-control-userforms-position.html)

Bob Phillips[_7_]

How to control the UserForm's position?
 
Try this

http://www.cpearson.com/excel/FormPosition.htm

--
HTH

Bob Phillips

"OKLover" wrote in message
...
Hello, All

Is anyone knows how to control the UserForm's position?
It seems that i couldn't to find the Screen.Width or Screen.Height

property
in VBA.





Harald Staff

How to control the UserForm's position?
 
There is no Screen object like in VB, and Excel's metrics is not pixels
either -at least not all over. But this places the userform down right on my
screen, no matter what and where the Excel window is:

Declare Function GetSystemMetrics32 Lib "user32" _
Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long

Public Const SM_CXSCREEN = 0
Public Const SM_CYSCREEN = 1

Sub test()
Dim X As Long, Y As Long
X = GetSystemMetrics32(SM_CXSCREEN)
Y = GetSystemMetrics32(SM_CYSCREEN)
With UserForm1
..StartUpPosition = 0
..Top = (Y - .Height - 50) * 0.71
..Left = (X - .Width - 50) * 0.71
..Show
End With
End Sub

Code modified from http://www.j-walk.com/ss/excel/tips/tip06.htm

HTH. Best wishes Harald

"OKLover" skrev i melding
...
Hello, All

Is anyone knows how to control the UserForm's position?
It seems that i couldn't to find the Screen.Width or Screen.Height
property in VBA.




OKLover

How to control the UserForm's position?
 
Thanks to Bob and Harald, i will try it. :D


"OKLover" l...
Hello, All

Is anyone knows how to control the UserForm's position?
It seems that i couldn't to find the Screen.Width or Screen.Height
property in VBA.




OKLover

How to control the UserForm's position?
 
Hello, All

Is anyone knows how to control the UserForm's position?
It seems that i couldn't to find the Screen.Width or Screen.Height property
in VBA.




All times are GMT +1. The time now is 08:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com