View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
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