Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default List Open Workbooks in VBA

James,

To list the workbooks to a list box, use the following:

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


To activate the workbook, use something like the following:

Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
With Me.ListBox1
Workbooks(.List(.ListIndex)).Activate
End With
End Sub



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"James B" wrote in message
...
Hi Everyone

Could someone please help me & advise how can I list all
open workbooks in a ListBox & allow user to select &
activate that workbook.
I have seen codes for worksheet listing for not for
workbook.
Thanks in advance fro your help

James
Excel 2002, Win 2k, VBA



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default List Open Workbooks in VBA

Thank you so much
It worked
-----Original Message-----
James,

To list the workbooks to a list box, use the following:

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


To activate the workbook, use something like the

following:

Private Sub ListBox1_DblClick(ByVal Cancel As

MSForms.ReturnBoolean)
With Me.ListBox1
Workbooks(.List(.ListIndex)).Activate
End With
End Sub



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"James B" wrote in

message
...
Hi Everyone

Could someone please help me & advise how can I list all
open workbooks in a ListBox & allow user to select &
activate that workbook.
I have seen codes for worksheet listing for not for
workbook.
Thanks in advance fro your help

James
Excel 2002, Win 2k, VBA



.

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
2 workbooks open Meg Excel Discussion (Misc queries) 3 December 16th 09 06:39 PM
when i open an Excell file 3 workbooks open.Why? Iain40 Excel Discussion (Misc queries) 2 February 3rd 09 05:04 PM
When I open Excel, workbooks open automatically. How can I stop t Rhealbird Excel Discussion (Misc queries) 2 February 23rd 06 10:08 AM
Workbooks.Open closes other workbooks S. Daum Excel Programming 1 August 21st 03 07:47 PM
Workbooks.Open / .Open Text - How do you stop the .xls addition? Dave[_20_] Excel Programming 2 July 31st 03 04:03 AM


All times are GMT +1. The time now is 08:40 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"