VBA CurDir: what is the use of this? Is there any practical example when you would use CurDir/ChDir etc instead of a simple path?

Jamualson

Board Regular
Joined
Feb 17, 2021
Messages
145
Office Version
  1. 2019
Platform
  1. Windows
I was wondering what is the use of CurDir, ChDir, etc in practice. Seems to me that using simple paths is always a much more clean way of doing things than curdir etc, which are way too overcomplicated. (ofc it comes from cmd and linux things, but I still don't have an idea why would somebody use this in Excel)

With CurDir / ChDir etc you can lose control. With paths you can not.

Thank you very much for your idea.
 
Last edited:

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
+another thing: you can still use activeworkbook.path, which gives back the folder the file is in, so this is another minus point for CDir and ChDrive functions etc.

Any feedback would be appreciated if I am missing some important point or not :) Thank you
 
Upvote 0
Hi Jamualson,

I'm not a VBA programmer but it would seem to me that you don't know where others will use your VBA.
e.g. If my current directory is C:\MrExcel\Toadstool then maybe I want to CurDir, MkDir a Temp directory and then put the results of my execution into there rather than hardcoding a results drive and directory.
 
Upvote 0
Hi Jamualson,

I'm not a VBA programmer but it would seem to me that you don't know where others will use your VBA.
e.g. If my current directory is C:\MrExcel\Toadstool then maybe I want to CurDir, MkDir a Temp directory and then put the results of my execution into there rather than hardcoding a results drive and directory.
Thank you for the answer. Yes, but this feature can be controlled by activeworkbook.path - according to me in a much more reliable way -, and we still don't loose flexibility. Thx for anybody who could confirm me or make me change my mind.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,962
Messages
6,122,482
Members
449,088
Latest member
Melvetica

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