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.
 

Some videos you may like

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

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!
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,561
Messages
5,512,073
Members
408,878
Latest member
stams

This Week's Hot Topics

  • Sort code advice please
    Hi, I have the code below which im trying to edit but getting a little stuck. This was the original code which worked fine,columns A-F would sort...
  • SUMPRODUCT with nested If statement
    Hi everyone, Hope you're all well. I'm hoping someone will be able to point me in the right direction with a problem I'm having with a SUMPRODUCT...
  • VBA - simple sort is killing me!
    Hello all! This should be so easy, but not for me, apparently! I have a table of data that can be of varying lengths and widths. My current macro...
  • Compare Two Lists
    I have two Lists and I need to be able to Identify differences between them. List 100 comes from a workbook - the other is downloaded form the...
  • Formula that deducts points for each code I input.
    I am trying to create a formula that will have each student in my class start at 100 points and then for each code that I enter (PP for Poor...
  • Conditional formatting formula required for day of week and a value
    Hi, I have a really simple spreadsheet where column A is the date, column B is the activity total shown as a number and column C states the day of...
Top