PDA

View Full Version : [SOLVED:] Browse open workbooks



Staticbob
01-25-2005, 04:24 AM
Guys,

I need to code a button to open a list of all open workbooks (ie - Window menu). The user should then select ONE of these, and this name be stored in a string variable.

Any sarters ?

Bob

Jacob Hilderbrand
01-25-2005, 04:49 AM
I would make a UserForm with a ListBox to show the workbook names.

Try this code.


Option Explicit

Private Sub CommandButton1_Click()
Dim WkbName As String
WkbName = Me.ListBox1.Text
If WkbName = "" Then
MsgBox "You did not select anything"
Else
MsgBox "You selected: " & WkbName
End If
End Sub

Private Sub UserForm_Initialize()
Dim Wkb As Workbook
For Each Wkb In Workbooks
Me.ListBox1.AddItem (Wkb.Name)
Next
End Sub


See attachment for more information.

Staticbob
01-25-2005, 07:04 AM
Thanks DRJ,


Just what I had in mind.

Bob

Jacob Hilderbrand
01-25-2005, 07:31 AM
You're Welcome :beerchug:

Take Care