Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 "fi.or.jp.de" wrote: 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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Barb, Works fine.
As you said what i should do if the user opened in another excel ?? Any Alternate solution. On Sep 20, 12:52*am, Barb Reinhardt wrote: 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 "fi.or.jp.de" wrote: 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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
fi.or.jp.de wrote:
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 this Private Sub UserForm_Initialize() Dim wb As Workbook For Each wb In Application.Workbooks ComboBox1.AddItem wb.Name Next End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
File:1 and File:2 -- Double Files when Opening One File | Excel Discussion (Misc queries) | |||
I saved file A over file B. Can I get file B back? | Excel Discussion (Misc queries) | |||
opening an excel file opens a duplicate file of the same file | Excel Discussion (Misc queries) | |||
I SAVED A FILE OVER ANOTHER A FILE IN EXCEL. THE OLD FILE WAS AN . | Excel Discussion (Misc queries) | |||
i received a file that reads powerpoint document file file exten. | Excel Discussion (Misc queries) |