Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
2 workbooks open | Excel Discussion (Misc queries) | |||
when i open an Excell file 3 workbooks open.Why? | Excel Discussion (Misc queries) | |||
When I open Excel, workbooks open automatically. How can I stop t | Excel Discussion (Misc queries) | |||
Workbooks.Open closes other workbooks | Excel Programming | |||
Workbooks.Open / .Open Text - How do you stop the .xls addition? | Excel Programming |