I have two monitors. On the right-one I have my 1st macro workbook. How will I open the 2nd workbook on the left-one with the macro(VBA), which is placed in the 1st workbook. THX
If you use this file on your own only and always in same cofig you could use some shortcut.
left
for primary monitor is = 0. If secondary monitor is on the left of primary then left
for it will be some number < 0 (depends on resolution).
It secondary is on the right then left
marking start of secondary monitor will be left
+ width
of excel window (if it's maximized).
Assuming that secondary monitor is on the left
This should work nice
Option Explicit
Public Sub NewWbk()
Dim Exl As Excel.Application
Set Exl = New Excel.Application
'here you'll need to change to open your file instead of adding new empty file
Exl.Workbooks.Add
Exl.Visible = True
With Exl.Application
.WindowState = xlNormal 'can't move maximized window
.Left = -500 'should work on most resolutions
.WindowState = xlMaximized
End With
End Sub
But this is very unreliable solution and may not work properly in many cases. What you should do is to use API calls, check number of monitors, check on which monitor your app is visible and decide where to open new file.
Take a look Here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.