Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Arranging Windows

I have a piece of code that creates a second window. I noticed that on only
one of the windows are the VBA control buttons active. When I arrange the
windows programatically using Application.Windows.Arrange to arrange the
windows horizontally, the window with the active buttons always is on the
bottom. Is there any way I can make sure that it's on top instead? I'm using
Excel 2000. Thank you.
--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Arranging Windows

Do you create the second window?

If you do, maybe you could keep track of what the activewindow was when you
started. And it sure looks like the activewindow ends up at the top when I
arrange them horizontally.

Option Explicit
Sub testme01()
Dim myWindow As Window
Set myWindow = ActiveWindow

Application.ScreenUpdating = False
myWindow.NewWindow
myWindow.Activate
Windows.Arrange arrangestyle:=xlArrangeStyleHorizontal, _
ActiveWorkbook:=True

Application.ScreenUpdating = True
End Sub

Worked for me.


J Streger wrote:

I have a piece of code that creates a second window. I noticed that on only
one of the windows are the VBA control buttons active. When I arrange the
windows programatically using Application.Windows.Arrange to arrange the
windows horizontally, the window with the active buttons always is on the
bottom. Is there any way I can make sure that it's on top instead? I'm using
Excel 2000. Thank you.
--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Arranging Windows


window 1 is always the activewindow..
also going thru the windows collection by number
will not produce the desired results..

so i tried following, I dont know if it is the 'proper' approach,
but it does seem to do the trick... :)

Get the names..
Sort them,
Activate in reverse order..
and then finally use Arrange

Produces the "first" window on top.




Sub ArrangeWindowsByName()
' 31-3-2005 by keepITcool

Dim i&, aNames
Application.ScreenUpdating = False
With ActiveWorkbook.Windows
'Store the names of the windows
ReDim aNames(1 To .Count)
For i = 1 To .Count
aNames(i) = .Item(i).Caption
Next
'Sort the names array
qSort aNames
'Activate in reverse order
For i = .Count To 1 Step -1
With .Item(aNames(i))
If .Visible Then .Activate
End With
Next
.Arrange ArrangeStyle:=xlHorizontal
End With
Application.ScreenUpdating = True

End Sub

Sub qSort(v, Optional n& = True, Optional m& = True)
Dim i&, j&, p, t
If n = True Then n = LBound(v): If m = True Then m = UBound(v)
i = n: j = m: p = v((n + m) \ 2)
While (i <= j)
While (v(i) < p And i < m): i = i + 1: Wend
While (v(j) p And j n): j = j - 1: Wend
If (i <= j) Then
t = v(i): v(i) = v(j): v(j) = t
i = i + 1: j = j - 1
End If
Wend
If (n < j) Then qSort v, n, j
If (i < m) Then qSort v, i, m
End Sub





--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


J Streger wrote :

I have a piece of code that creates a second window. I noticed that
on only one of the windows are the VBA control buttons active. When I
arrange the windows programatically using Application.Windows.Arrange
to arrange the windows horizontally, the window with the active
buttons always is on the bottom. Is there any way I can make sure
that it's on top instead? I'm using Excel 2000. Thank you.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Arranging the VBA console windows Dallman Ross Excel Discussion (Misc queries) 2 October 26th 06 04:42 PM
re-arranging the data Lan Excel Discussion (Misc queries) 2 August 16th 06 04:52 PM
Need help arranging chart [email protected] Excel Discussion (Misc queries) 1 July 28th 06 10:28 PM
re-arranging worksheets blazon Excel Discussion (Misc queries) 4 September 22nd 05 04:57 PM
Arranging columns Himu Excel Worksheet Functions 3 July 24th 05 04:57 AM


All times are GMT +1. The time now is 04:31 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"