Current Directory Info is incorrect

WILLIAM DEMUTH

New Member
Joined
Jul 19, 2010
Messages
16
Hello

I am having a problem with Excel involving current directories.

To diagnose my issue I created a basic macro that shows my path.

Code:
Sub WhereAmI()
MsgBox CurDir
End Sub

My concern is after I use a different macro to save to a different drive, when I run WhereAmI again, it seems to give the last directory the file was in, rather than the one it currently is in.

What am I missing? I have no doubt it should be obvious to me, but it has me stumped.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Perhaps I wasn't clear. I am moving to a different machine ( either to a network drive, or to a local drive)

Is there a better option to show where the file actually is at any moment?

Surprisingly, (At least to me) when I access the traditional save menu to see where I am and then rerun the macro (without saving anything) the result is correct.
 
Upvote 0
And please note I am changing the file name when the drive change is done. I suspect that may be involved.

Regards to Manor Way!
 
Upvote 0
Perhaps

Code:
Sub WhereAmI()
MsgBox ThisWorkbook.Path
End Sub

Which shows the workbook's path not which folder you are currenly in.
 
Upvote 0
Brilliant in its simplicity :biggrin:

Solves my issue, but still don't understand why Excel seems to not see the change

In any event many thanks!
 
Upvote 0

Forum statistics

Threads
1,214,657
Messages
6,120,764
Members
448,991
Latest member
Hanakoro

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