![]() |
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 |
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 . |
All times are GMT +1. The time now is 12:03 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com