Userform on two monitors

Joined
May 7, 2014
Messages
1
Reaction score
0
Hello out there,
first of all excuse my bad english. I'm a newbie on VBA and can't find a solution to my problem. Here's a short explanation what I'm searching for.

I have a custom form with a dropdownlist and an OK button which should open centered in the outlook main window, but - now it comes - I'm using two monitors.

When I try to center the custom form it appears just on the position which is the center of both monitors (sorry, I can't post a screenshot cause I don't have enough posts, but you can have see it at - img.neurieser.eu/foren/pcreview/GLN_327.jpg - It should appear centered within the outlook window.

Here comes the code:
Code:
Private Sub UserForm_Initialize()

Dim x As Long
Dim y As Long
Dim t As Long
Dim l As Long
Dim mx As Long ' middle witdth of window
Dim my As Long ' middle height of window
Dim fx As Long ' left side of windows
Dim fy As Long ' top of window

x = ActiveWindow.Width
y = ActiveWindow.Height
t = ActiveWindow.Top
l = ActiveWindow.Left

mx = CLng(x / 2) + t
my = CLng(y / 2) + l

' left side userform, Offset
Me.Left = mx - CLng(Me.Width / 2)

' top userform, Offset
Me.Top = my - CLng(Me.Height / 2)

End Sub
Has anyone an idea how I could solve this issue?


Thanks in advance
 
Back
Top