how to open the directory window and then stop ?

jokkebal

New Member
Joined
Jun 26, 2014
Messages
18
Hi,
I want my macro to perform some actions, and the last one is to open a specific folder in which I then can choose a file to open. I don't want the macro to open the file, because I want to choose the file that the macro is going to open.

How can I guide the macro to open the correct file subfolder ?

This is what I have (and works) :


vFile = Application.GetOpenFilename("Excel Files (*.xl*)," & "*.xl*", 1, "Select Excel File", "Open", False)

(here I select the file)

Workbooks.Open vFile




So, what is missing, is the instruction to go and look into the correct folder. To my surprise, the following line is not working :

ChDir "\\fs01\Data\Breemes\CSS2\Flows\Accordion Files\A In Process"

Thanks and best wishes to everyone !
Josse.
 
Last edited:

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
ChDir works just fine for me and should for you, too. Maybe there is an issue with your directory? Try a different directory and see if it works... also you're putting the ChDir command before trying to open the file, right?

Rich (BB code):
ChDir "\\fs01\Data\Breemes\CSS2\Flows\Accordion Files\A In Process"
vFile = Application.GetOpenFilename("Excel Files (*.xl*)," & "*.xl*", 1, "Select Excel File", "Open", False)
Workbooks.Open vFile
 
Last edited:
Upvote 0
Hi Sven,
Thanks for your reply. It works !
"Maybe there is an issue with your directory" : That was it. I recorded the whole action in a macro and saw a difference in the way the macro wrote the directory.
Apparently, there are two (or more) ways to describe a path, where one is not wrong (no error message or stopping macro) but not good enough for the next step...

Best regards,
Josse.
 
Last edited:
Upvote 0
Yes and no : replaced "\\fs01\Data\" with "K:"
The funny thing is that the first didn't seem to be wrong; I didn't receive any error message...
Anyhow, solved !!
 
Upvote 0

Forum statistics

Threads
1,223,630
Messages
6,173,453
Members
452,514
Latest member
cjkelly15

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