Info("Directory")

B

BigWoof

I am using the info("directory") function to provide the current directory of
where my worksheet is. Unfortnately, the function seems to be returning my
default excel work directory instead of the directory where the spreadsheet
is located - which is clearly not working as documented.

Can anyone tell me 1) is this a legit problem or am I reading the
documentation wrong?
2) Is there a workaround to the problem or is ther another function I can
use to get the current excel file location?
Many thanks
 
P

Peg

I believe info returns the current directory, which
equates to the directory most recently used in File
Open... (even if you cancel). You can use the cell
("filename") function to get the current file path, as in
=LEFT(CELL("filename",A1),FIND("[",CELL("filename",A1))-2)
This will return only the path (it returns #VALUE if the
file hasn't been saved yet).
 
B

BigWoof

More info - I am running Excel 2003. Could it be possible that the problem
is somehow connected to the new autorecovery feature?
 
D

Dave Peterson

I use xl2002 which also has autorecovery.

In that version, autorecovery wasn't a problem.

But =info("directory") returns the current directory--not the directory that
holds the file you're working on.

And this could change when you open a file or save a file.

(or even use some VBA code to change folders.)

But Peg's formula did work for me:
=LEFT(CELL("filename",A1),FIND("[",CELL("filename",A1))-2)
 
Top