How to select or open file folder and then choose a file using forms.

dariusd77

New Member
Joined
Jan 24, 2013
Messages
26
So lets say i want to have a spin button that scrolls through each month of the year(or drop down button). And each month is the name of each folder.. how do I do that.. How do i select at folder level not at the file level in the folder ..Because after they select folder then i want a form to come up that the user can then use to select the file. Each month will have the same number of files with the same name.
Example
folder january
file 1
file 2
folder February
file 1
file 2
folder March
file 1
file 2
each month ..........

So basically they will first choose the month they want using a spin button or drop down box..which = a particular folder

ie. C:\Users\ddempsey\Desktop\projects\dashboard project\MSO dashboard\New folder\Jan
ie C:\Users\ddempsey\Desktop\projects\dashboard project\MSO dashboard\New folder\Feb

once they selected the folder(month).another form(using command buttons or option buttons) will show up giving them 5 choices..which are 5 files.. within each folder, and each file is named exactly the same in each folder.

ie C:\Users\ddempsey\Desktop\projects\dashboard project\MSO dashboard\New folder\Jan\2013 Open Jobs
ie C:\Users\ddempsey\Desktop\projects\dashboard project\MSO dashboard\New folder\Jan\2013 Open orders
ie C:\Users\ddempsey\Desktop\projects\dashboard project\MSO dashboard\New folder\Feb\2013 Open Jobs
ie C:\Users\ddempsey\Desktop\projects\dashboard project\MSO dashboard\New folder\Feb\2013 Open orders
 
No, it's not case sensitive. You did use backslashes right? in your quote of my text above it shows up as "|".

Easiest way to troubleshoot at this point is to use the Immediate window. If it's not visible in VBA then go to the View menu and enable it.

Add this line to your code, right before attempting to open the workbook:

Debug.Print strFileName

Once the code ends and/or the error occurs, look down in the immediate window and review the file path there. Look very closely for extra spaces, especially at the very end of the line.

Next, type this into a new line in the immediate window, then push the enter key to execute:

Workbooks.Open ("C:\Users\ddempsey\Desktop\projects\dashboard project\MSO dashboard\New folder\July\FSO Open Report.xls")

Does the file open?
 
Upvote 0

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
I rewsolved the problem. It works now. It apeears i cannot be in the folder when running the code. Once I got out of the folder the file exist in and the ran the Code it worked fine and open up the file. Now I have to figure out how to reopen the form from the workbook, because i have it set up to close or hide the form when the workbook/file is open . Now I am tryin gto reopen the from by clicking on a button that will be at the top of the worksheet.
 
Upvote 0
Doesn't matter, whichever you prefer. Form buttons are probably simpler and less prone to issues.
 
Upvote 0
Are you sure you spelled that right? Did you mean frmuserFormExample? You typed Fomr
 
Upvote 0
There's not much that can go wrong with that line of code other than a misspelled name. Try this: close and reopen the file. Go to the immediate window in VBA and type that line, then push enter, see if it loads.

frmuserFormExample.Show
 
Upvote 0

Forum statistics

Threads
1,223,738
Messages
6,174,213
Members
452,551
Latest member
croud

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