Filehost.ro - gazduire fisiere
Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
Nou pe simpatie:
sexyindianca
Femeie
24 ani
Ilfov
cauta Barbat
24 - 53 ani
Mrrrr's Forum (VIEW ONLY)ReguliInregistrareLoginPozeNu sunteti logat. Lista Forumurilor Pe Tematici
Mrrrr's Forum (VIEW ONLY) / Tutoriale si Ghiduri Utile // Tutorials and useful guides /

[EXCEL] Move ActiveWindow to The 2nd Monitor and Back [VBA]

Pagini: 1 Moderat de TRaP, TonyTzu
#1
TRaP
Moderator
Postari: 960
Source:
http://mrrrr.3xforum.ro/post/1803/1/WOR ... Back_VBA_/



' CHECK PROPERTIES OF ACTIVE WINDOW ON EACH MONITOR
Sub CheckObjectProps()
Dim winActive As Window
Set winActive = ActiveWindow
    Debug.Print winActive.WindowState 'open Immediate window (CTRL+G) to see values
                '1 = wdWindowStateMaximize, 0 = wdWindowStateNormal, 2 = wdWindowStateMinimize
    Debug.Print winActive.Height 'open Immediate window (CTRL+G) to see values
    Debug.Print winActive.Width 'open Immediate window (CTRL+G) to see values
    Debug.Print winActive.Top 'open Immediate window (CTRL+G) to see values
    Debug.Print winActive.Left 'open Immediate window (CTRL+G) to see values
    Stop ' open Locals window to inspect more properties of winActive
Set winActive = Nothing
End Sub

Sub ToMonitor()
Dim winActive As Window
Set winActive = ActiveWindow
Application.ScreenUpdating = False

With winActive
    .WindowState = xlNormal
    .Height = 816 'laptop = 507
    .Width = 1446 'laptop = 1030,5
    .Top = -236 'laptop = -2
    .Left = -1442 'laptop = -2
    .WindowState = xlMaximized
End With
Application.ScreenUpdating = True
End Sub

Sub ToLaptop()
Dim winActive As Window
Set winActive = ActiveWindow
Application.ScreenUpdating = False

With winActive
    .WindowState = xlNormal
    .Height = 507 'monitor = 816
    .Width = 1030.5 'monitor = 1446
    .Top = -2 'monitor = -236
    .Left = -2 'monitor = -1442
    .WindowState = xlMaximized
End With

Application.ScreenUpdating = True
End Sub


 
   
pus acum 4 zile#2
TRaP
Moderator
Postari: 960
Easiest way nowadays in Windows 11 is without VBA at all, with 2 options:

1. Move the window maximized, pressing: WIN + SHIFT + Left/Right arrow keys

2. Snap the window to edges of the screen:  WIN + Left/Right arrow keys and WIN + Up arrow key to maximize and WIN + Down arrow key to minimize

Notes:
These options move the window cleanly on the taskbar provided that you have set up for the window to show on the taskbar only on the screen where the window is open.
Dragging the window from one screen to another with your mouse does not seem to be a good solution, as you turn up with windows on the taskbar on one screen, but opening on the other screen.


 
   
Pagini: 1  
Mergi la