Detect top, left & height of activeworkbook? How do?

C

Chet

Anyone know how to detect the position (top, left & ht) of a given
open workbook? I am trying to show all open workbooks in a flowing
style so I can see them all. I know that the cascade style position
exists but I want to have more control over the position of each of
these open workbooks so I can see them better.

Thanks, Chet
 
P

Peter T

Try something like this -

Sub Cascader()
Dim cnt As Long, i As Long, n As Long
Dim w As Single, h As Single
Dim wn As Window

Application.ScreenUpdating = False
Application.WindowState = xlMaximized

With ActiveWindow
.WindowState = xlMaximized
w = .Width - 6
h = .Height - 24
End With

ReDim saNames(1 To Application.Windows.Count)

With Application.Windows
For i = 1 To .Count
With .Item(i)
If .Visible Then
cnt = cnt + 1
saNames(cnt) = .Caption
End If
End With
Next
End With

Application.EnableEvents = False

With Application.Windows

For i = cnt To 1 Step -1
Set wn = .Item(saNames(i))
With wn
.WindowState = xlNormal
.Activate
.Left = n * 21 + 3
.Top = n * 24 + 3
.Width = w - .Left
.Height = h - .Top - 3

If .Top > h * 0.7 Then n = 0
End With

n = n + 1
Next

End With

Application.ScreenUpdating = True
Application.EnableEvents = True

End Sub


Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top