Macro to get the directory

YCJ

New Member
Joined
Feb 28, 2011
Messages
29
Hi all,

I need some help here. Can somebody guide me on how to get the directory of the excel file i'm currently opening using macro? :confused:

Thanks in advance,
CJ
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
When you open a workbook, it becomes by default the active workbook at that moment. So to know the directory of that active workbook, you can press Alt+F11 then Ctrl+G and type or paste ? activeworkbook.Path and press the Enter key.

If you want to know the path programmatically as you open the workbook, I would wonder why you'd not already know that, seeing as you'd have needed to know where the workbook was when you presumably navigated to some folder path in order to open it.
 
Upvote 0
Oh, because i need to open another file under the same folder in my program. I don't wish to fix the location because I want the folder to work from any location in the computer. If I fix the location in my program, then I would need to paste this folder in the same location in another computer.

Thanks for your response,
CJ
 
Upvote 0
Oh, because i need to open another file under the same folder in my program.

OK, that would mean you want to know that path of the workbook running the macro, which would be derived by
ThisWorkbook.Path
 
Upvote 0
OH...okay i see...sorry i'm still new with this macro thing. Not really familiar with it, thanks for your help. Have a nice day.

CJ
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,734
Members
452,939
Latest member
WCrawford

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