Sub Launch_UserForm1()
With UserForm1
.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
Sub Launch_UserForm()
'--Addresses Dual Screen problem by launching Userform in Maximized Application
' --TopLeft position saved in Userform Properties at Design Time are used
' --in relation to Maximized Application
Dim lDsnLeft As Long, lDsnTop As Long
With Application
If .WindowState <> xlMaximized Then _
.WindowState = xlMaximized
End With
With UserForm1
'---Read UserForm Settings saved at Design Time
lDsnLeft = .Left
lDsnTop = .Top
.StartUpPosition = 0
.Left = Application.Left + lDsnLeft
.Top = Application.Top + lDsnTop
.Show
End With
End Sub
You could use the code below to have the Userform displayed on the correct monitor in the same position that it would show up if it were a single monitor with the Excel Application Window Maximized.
Code:Sub Launch_UserForm() '--Addresses Dual Screen problem by launching Userform in Maximized Application ' --TopLeft position saved in Userform Properties at Design Time are used ' --in relation to Maximized Application Dim lDsnLeft As Long, lDsnTop As Long With Application If .WindowState <> xlMaximized Then _ .WindowState = xlMaximized End With With UserForm1 '---Read UserForm Settings saved at Design Time lDsnLeft = .Left lDsnTop = .Top .StartUpPosition = 0 .Left = Application.Left + lDsnLeft .Top = Application.Top + lDsnTop .Show End With End Sub
Getting the userform to show at "a very specific place" requires defining that phrase.
The .Left and .Top Properties of the UserForm are expressed in Pixels so depending on the User's screen resolution; placing the UserForm at .Left = 500.25 could place it Left of Center or far Right of Center.
If your application tool is just for your use; or users that all have the same screen resolution then this might not be a problem.
Sub LaunchIT(WhichOne)
With WhichOne 'SelectLocation
.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
Public Sub LaunchIT(sWhichOne As String)
With VBA.UserForms.Add(sWhichOne)
.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
Sub Test()
Call LaunchIT("UserForm1")
End Sub