kuku1375
Advanced Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Public Sub WindowTileVertical() Dim oWind As Window ' working object Dim nActiveWindowIndex As Long ' save to reactivate at end Dim nNonMinWindows() As Long ' list of nonminimized windows Dim nNonMinWindowsCount As Long ' length of the list Dim nScreenWidth As Long ' width & height of full Dim nScreenHeight As Long ' screen in points Dim nDesiredWidth As Long ' width each window should be Dim nIndex As Long ' For loop index ' Save active window's index nActiveWindowIndex = ActiveWindow.Index ' Find out how many Word windows are not minimized ' (i.e., maximized or normal), and store them in the ' nNonMinWindows array nNonMinWindowsCount = 0 For Each oWind In Windows If oWind.WindowState <> wdWindowStateMinimize Then nNonMinWindowsCount = nNonMinWindowsCount + 1 ReDim Preserve nNonMinWindows(nNonMinWindowsCount - 1) nNonMinWindows(nNonMinWindowsCount - 1) = oWind.Index End If Next oWind If nNonMinWindowsCount < 1 Then Exit Sub ' Maximize the current window, to get the ' screen width and height in points With ActiveWindow .WindowState = wdWindowStateMaximize nScreenWidth = .Width nScreenHeight = .Height End With ' The desired width is the screen width ' divided by the number of windows being tiled nDesiredWidth = nScreenWidth / nNonMinWindowsCount ' Set each window to the desired size. Offset each one ' horizontally to sit to the right of the one before. For nIndex = 0 To nNonMinWindowsCount - 1 Set oWind = Windows(nNonMinWindows(nIndex)) With oWind .Activate .WindowState = wdWindowStateNormal .Width = nDesiredWidth .Height = nScreenHeight .Top = 0 .Left = nIndex * nDesiredWidth End With Next nIndex Set oWind = Nothing Windows(nActiveWindowIndex).Activate End Sub |