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

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Saving a file to another folder won't change your current folder.
 

WILLIAM DEMUTH

New Member
Joined
Jul 19, 2010
Messages
16
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.
 

WILLIAM DEMUTH

New Member
Joined
Jul 19, 2010
Messages
16
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!
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Perhaps

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

Which shows the workbook's path not which folder you are currenly in.
 

WILLIAM DEMUTH

New Member
Joined
Jul 19, 2010
Messages
16
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!
 

Forum statistics

Threads
1,141,410
Messages
5,706,293
Members
421,439
Latest member
JordsdoExcel

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
Top