VBA/Excel/Access/Word/Application/Windows

Материал из VB Эксперт
Перейти к: навигация, поиск

Arranging and Resizing Windows: ppWindowMaximized, ppWindowMinimized, or ppWindowNormal.

   <source lang="vb">

Sub windowState()

   Application.WindowState = ppWindowMaximized
   Windows.Arrange ArrangeStyle:=ppArrangeCascade

End Sub

</source>
   
  


Closing a Window

   <source lang="vb">

Sub close()

   Do While ActiveWorkbook.Windows.Count > 1
       ActiveWorkbook.Windows(myWorkbook.Windows.Count).Close
   Loop

End Sub

</source>
   
  


How to arrange the windows: as icons (wdIcons, 1) or tiled (wdTiled, 0). The default is wdTiled.

   <source lang="vb">

Sub arrange()

   Windows.arrange ArrangeStyle:=wdTiled

End Sub

</source>
   
  


Split windows

   <source lang="vb">

Sub SplitWindow()

 Dim freezeMode, win As Window
 If TypeName(ActiveSheet) <> "Worksheet" Then Exit Sub
 Set win = ActiveWindow
 freezeMode = win.FreezePanes
 win.FreezePanes = False       "else the split cannot be changed
 If win.Split Then win.Split = False: Exit Sub  "cancel split
 win.SplitRow = ActiveCell.Row - win.ScrollRow
 win.SplitColumn = ActiveCell.Column - win.ScrollColumn
 win.FreezePanes = freezeMode   "restore split

End Sub

</source>
   
  


transform all windows into icons

   <source lang="vb">

Sub ShowWindowsAsIcons()

 Dim win As Object
 For Each win In Windows
   If win.Visible Then win.WindowState = xlMinimized
 Next win

End Sub

</source>
   
  


Working with the Active Window

   <source lang="vb">

"To make sure that a window is open, check whether the Count property of the Windows collection is 0 Sub open()

   If Windows.Count = 0 Then MsgBox "There is no active window.", vbOkOnly + _
       vbExclamation, "No Window Is Open"

End Sub

</source>