ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Exclude hidden workbooks from list (https://www.excelbanter.com/excel-programming/348743-exclude-hidden-workbooks-list.html)

Duke Carey

Exclude hidden workbooks from list
 
I'd like to list all open - but NOT hidden - workbooks in a userform listbox.
However, I am unable to find any properties that tell if a book is hidden or
not.

You can try to activate each book and test for success, I suppose, but there
has to be a more elegant way than that. Isn't there?

chijanzen

Exclude hidden workbooks from list
 
Duke:

try,

Private Sub UserForm_Initialize()
Dim wbk As Workbook
For Each wbk In Workbooks
If wbk.Windows(1).Visible = True Then
Me.ListBox1.AddItem wbk.Name
End If
Next
End Sub

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Duke Carey" wrote:

I'd like to list all open - but NOT hidden - workbooks in a userform listbox.
However, I am unable to find any properties that tell if a book is hidden or
not.

You can try to activate each book and test for success, I suppose, but there
has to be a more elegant way than that. Isn't there?


Jim Cone

Exclude hidden workbooks from list
 
Duke,

For Each WkBk in Workbooks
If WkBk.Windows(1).Visible Then
'- - - -
Next

Regards,
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Duke Carey"

wrote in message
...
I'd like to list all open - but NOT hidden - workbooks in a userform listbox.
However, I am unable to find any properties that tell if a book is hidden or
not.
You can try to activate each book and test for success, I suppose, but there
has to be a more elegant way than that. Isn't there?

Duke Carey

Exclude hidden workbooks from list
 
Much simpler, and very effective. Thanks

"chijanzen" wrote:

Duke:

try,

Private Sub UserForm_Initialize()
Dim wbk As Workbook
For Each wbk In Workbooks
If wbk.Windows(1).Visible = True Then
Me.ListBox1.AddItem wbk.Name
End If
Next
End Sub

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Duke Carey" wrote:

I'd like to list all open - but NOT hidden - workbooks in a userform listbox.
However, I am unable to find any properties that tell if a book is hidden or
not.

You can try to activate each book and test for success, I suppose, but there
has to be a more elegant way than that. Isn't there?



All times are GMT +1. The time now is 12:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com