adamdavi3s
New Member
- Joined
- Feb 3, 2011
- Messages
- 2
Hi All!
Long time lurker, first time poster!
I've compiled a set of VBA from various places on the web, to allow users to manipulate their excel session to take account of multiple monitors.
This works perfectly for people with the second screen on the right of their main, however I can not get it working for people with them on the left!
The key piece of code I am having problems with, is application.width
The working code is:
Which works perfectly for a right hand screen, give or take a few pixels.
When altering it for the left hand screen:
It just will NOT work! It places the application perfectly on the left screen and corrects the height as expected, however it will not stretch the screen onto the primary monitor!!!
Even if I hard code this figure to 10,000 it just refuses to work!
Any ideas??
many thanks in advance!
Long time lurker, first time poster!
I've compiled a set of VBA from various places on the web, to allow users to manipulate their excel session to take account of multiple monitors.
This works perfectly for people with the second screen on the right of their main, however I can not get it working for people with them on the left!
The key piece of code I am having problems with, is application.width
The working code is:
Code:
Option Explicit
Declare Function GetSystemMetrics _
Lib "user32.dll" ( _
ByVal nIndex As Long) _
As Long
Const SM_CXSCREEN = 0
Const SM_CYSCREEN = 1
Const SM_CXVIRTUALSCREEN = 78
Const SM_CYVIRTUALSCREEN = 79
Const SM_XVIRTUALSCREEN = 76
Const SM_YVIRTUALSCREEN = 77
Public dtop As Long, dleft As Long, dheight As Long, dwidth As Long
Sub side_by_side()
With Application
.WindowState = xlNormal
.Top = 0
.Left = 0
.Height = GetSystemMetrics(SM_CYSCREEN) - 225
.Width = GetSystemMetrics(SM_CXVIRTUALSCREEN) - 500
End With
Windows.Arrange ArrangeStyle:=xlVertical
End Sub
When altering it for the left hand screen:
Code:
Option Explicit
Declare Function GetSystemMetrics _
Lib "user32.dll" ( _
ByVal nIndex As Long) _
As Long
Const SM_CXSCREEN = 0
Const SM_CYSCREEN = 1
Const SM_CXVIRTUALSCREEN = 78
Const SM_CYVIRTUALSCREEN = 79
Const SM_XVIRTUALSCREEN = 76
Const SM_YVIRTUALSCREEN = 77
Public dtop As Long, dleft As Long, dheight As Long, dwidth As Long
Sub side_by_side()
With Application
.WindowState = xlNormal
.Top = 0
.Left = (GetSystemMetrics(SM_CXVIRTUALSCREEN) - GetSystemMetrics(SM_CXSCREEN) - 315) * -1
.Height = GetSystemMetrics(SM_CYSCREEN) - 225
.Width = GetSystemMetrics(SM_CXVIRTUALSCREEN) - 500
End With
Windows.Arrange ArrangeStyle:=xlVertical
End Sub
Even if I hard code this figure to 10,000 it just refuses to work!
Any ideas??
many thanks in advance!