ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How can I Center a Dialog Box each time a user opens it? (https://www.excelbanter.com/excel-programming/376061-how-can-i-center-dialog-box-each-time-user-opens.html)

Bandit

How can I Center a Dialog Box each time a user opens it?
 
I have a custom dialog box with dropdrowns etc used to select options.
Each time you click the command buttion that shows the dialog box the box
moves towards the upper left corner of the worksheet? How can I center the
dialog each time it is shown?. Are there methods to control the position of a
dialog using VBA or other means?

Zone

How can I Center a Dialog Box each time a user opens it?
 
Bandit, if you're talking about a userform, follow these steps:
1. Display the userform in the VBA editor
2. Display the userform properties.
3. In the userform properties, set Startup Position to manual.
4. Copy this code and paste to your userform module:

Private Sub UserForm_Initialize()
Me.Left = Application.Width / 2 - Me.Width / 2
Me.Top = Application.Height / 2 - Me.Height / 2
End Sub

James

Bandit wrote:
I have a custom dialog box with dropdrowns etc used to select options.
Each time you click the command buttion that shows the dialog box the box
moves towards the upper left corner of the worksheet? How can I center the
dialog each time it is shown?. Are there methods to control the position of a
dialog using VBA or other means?




All times are GMT +1. The time now is 02:02 AM.

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