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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
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,224,820
Messages
6,181,157
Members
453,021
Latest member
Justyna P

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