File name

F

fi.or.jp.de

I have userform, where combobox need show the file names.

Suppose i have opened 5 excel files as A.xlsx, B.xlsx, C.xlsm, D.xlsx,
E.xlsx

All the 5 files names should be available in Combo Box.

Thanks in advance
 
B

Barb Reinhardt

Try something like this

Private Sub UserForm_Initialize()
Dim WB As Excel.Workbook

For Each WB In Application.Workbooks
'Change UserFormName to the name of your user form. Also change the
Combobox name as needed
UserformName.Controls("Combobox1").AddItem (WB.Name)
Next WB
Me.ComboBox1.Text = "Select a workbook."

End Sub

Keep in mind that this will work for all workbooks opened in the current
excel instance. If workbooks are opened in another excel instance, they
won't be seen.

HTH,
Barb Reinhardt
 
F

fi.or.jp.de

Thanks Barb, Works fine.

As you said what i should do if the user opened in another excel ??

Any Alternate solution.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top