How to open files from an AxitiveX combobox list that is populated by a macro?

mflury

New Member
Joined
Mar 19, 2019
Messages
5
Hello,

Long time answer searcher, first time poster. Still limited macro knowledge but I have usually been able to solve my macro-writing problems with a few searches and sometimes cobbling together different answers that I find online. No such luck this time.

I have the macro below (found the outline for it online) that runs when the workbook opens. "PATH" is shortened for convenience. The macro below works great. Any files in the "Individual Workbooks" folder are shown in the ActiveX combobox drop-down list. Perfect for what I need.

What is not perfect is that I also need a user to be able to click on their individual file in the drop-down list and have that file open. I have been unable to find anything online that will work.

Any assistance will be appreciated!

Thanks!




Code:
Private Sub Workbook_Open()



Sheet1.ComboBox1.Clear


Sheet1.ComboBox1.List = Filter(Split(CreateObject("wscript.shell").exec("cmd /c Dir ""PATH\Individual Workbooks"" /b /a-d /on").stdout.readall, vbCrLf), ".")


End Sub
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Try:-
Change file Path in code as required:-
Place code in Combobox1 code module

Code:
Private Sub ComboBox1_Change()
Workbooks.Open "C:\Users\USER1\Desktop\old Stuff\" & ComboBox1.Value
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,432
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top