LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Count visible windows

Sub test()
Dim nVisCnt As Long
Dim nHiddenCnt As Long
Dim wn As Window

For Each wn In Application.Windows
If wn.Visible Then
nVisCnt = nvis.cnt + 1
Else
nHiddenCnt = nHiddenCnt + 1
End If
Next

MsgBox "Visible: " & nVisCnt & vbCr & _
"Hidden: " & nHiddenCnt, , "Windows"

End Sub

You might also want to check how many windows your own wb has in case user
did a "New Window" (which may or may not be hidden) but exclude any selected
worksheets charts is applicable.

Maybe this might be a better approach -

Sub test2()
Dim nOtherWBWindowVis As Long
Dim wn As Window
Dim wb As Workbook

For Each wb In Application.Workbooks
If wb.Name < ThisWorkbook.Name Then
For Each wn In wb.Windows
If wn.Visible Then
nOtherWBWindowVis = nOtherWBWindowVis + 1
Exit For
End If
Next
End If
Next
MsgBox "Other Visible Workbooks: " & nOtherWBWindowVis

End Sub

Yet another approach might be to loop wb's and check if any exist (even
hidden) that are not Personal.xls or "myBookName.xls"

Regards,
Peter T


"Kevin" wrote in message
...
I would like to have excel close when my workbook closes but only if there
are no other workbooks open. However depending on how many hidden

workbooks
are open the application.windows.count value will always show more than

one
workbook open.

How can I count only the visible windows and ignore things that are hidden
like personal.xls?



 
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
How to keep Status count visible? TotallyConfused Excel Worksheet Functions 1 September 12th 08 06:55 PM
Windows Visible Property - Code Help Gerry O Excel Discussion (Misc queries) 2 September 6th 07 02:44 AM
Count Visible Range? Matt[_39_] Excel Programming 4 August 1st 06 02:27 AM
count only visible cells bnkone Excel Worksheet Functions 2 March 31st 06 01:39 AM
Count Visible Sean[_7_] Excel Programming 2 May 4th 04 06:33 PM


All times are GMT +1. The time now is 08:59 AM.

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

About Us

"It's about Microsoft Excel"