View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Dialog Box List of Current Open Workbooks

Frank,

Create a UserForm with a list box and a command button, in put
the following code in the form's code module:

Private Sub CommandButton1_Click()
Dim WB As Workbook
With Me.ListBox1
Set WB = Workbooks(.List(.ListIndex))
' do something with WB
End With
End Sub

Private Sub UserForm_Initialize()
Dim WB As Workbook
With Me.ListBox1
For Each WB In Workbooks
.AddItem WB.Name
Next WB
.ListIndex = 0
End With
End Sub


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


"Frank & Pam Hayes" wrote in message
...
I am lookng for an example of VBA code that will produce a

dialog box of all
the currently opened Excel Workbooks and will allow the user to

select which
of the open Workbooks they would like to perform an action on.

Can anyone point me in the right direction? I have tried

multiple Google
searches and the closest I could come is code to open Workbooks

from the
directory.

Thank you,

Frank