File name

  • Thread starter Thread starter fi.or.jp.de
  • Start date Start date
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
 
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
 
Thanks Barb, Works fine.

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

Any Alternate solution.
 
Back
Top