VBA/Excel/Access/Word/Application/Windows — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 16:33, 26 мая 2010
Содержание
Arranging and Resizing Windows: ppWindowMaximized, ppWindowMinimized, or ppWindowNormal.
Sub windowState()
Application.WindowState = ppWindowMaximized
Windows.Arrange ArrangeStyle:=ppArrangeCascade
End Sub
Closing a Window
Sub close()
Do While ActiveWorkbook.Windows.Count > 1
ActiveWorkbook.Windows(myWorkbook.Windows.Count).Close
Loop
End Sub
How to arrange the windows: as icons (wdIcons, 1) or tiled (wdTiled, 0). The default is wdTiled.
Sub arrange()
Windows.arrange ArrangeStyle:=wdTiled
End Sub
Split windows
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
transform all windows into icons
Sub ShowWindowsAsIcons()
Dim win As Object
For Each win In Windows
If win.Visible Then win.WindowState = xlMinimized
Next win
End Sub
Working with the Active Window
"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