ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I GetCurrentDirectory in Excel? (https://www.excelbanter.com/excel-programming/404508-how-do-i-getcurrentdirectory-excel.html)

Thunderbolt2000

How do I GetCurrentDirectory in Excel?
 
I need to retrieve the current drive letter to use in my Excel spreadsheet,
how do I retrieve it?

carlo

How do I GetCurrentDirectory in Excel?
 
Hi Thunderbolt

if you want to have the drive letter (only the letter) you could use
following:
=LEFT(CELL("filename",A1),1)
otherwise to get the whole path, just use the cell function i used.

hth
Carlo

On Jan 18, 10:10*am, Thunderbolt2000
wrote:
I need to retrieve the current drive letter to use in my Excel spreadsheet,
how do I retrieve it?



Jean-Yves[_2_]

How do I GetCurrentDirectory in Excel?
 
Hi,
try msgbox CurDir

Regards
JY

"Thunderbolt2000" wrote in
message ...
I need to retrieve the current drive letter to use in my Excel spreadsheet,
how do I retrieve it?




Chip Pearson

How do I GetCurrentDirectory in Excel?
 
"carlo" wrote in message
news:834afa11-a96b-4fa0-bd7d-
=LEFT(CELL("filename",A1),1)


That returns the drive letter of the workbook name, which is not necessarily
the drive of the current working directory. Moreover, it is possible, though
not at all likely, that the drive letter may have two characters (if you
have a LOT of partitions and/or mapped drives).

Instead, use code like the following:

Function CurrentDrive() As String
Application.Volatile True
CurrentDrive = Split(CurDir, ":")(0)
End Function

You can then call this from a worksheet cell with

=CurrentDrive()

--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2008
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



"carlo" wrote in message
...
Hi Thunderbolt

if you want to have the drive letter (only the letter) you could use
following:
=LEFT(CELL("filename",A1),1)
otherwise to get the whole path, just use the cell function i used.

hth
Carlo

On Jan 18, 10:10 am, Thunderbolt2000
wrote:
I need to retrieve the current drive letter to use in my Excel
spreadsheet,
how do I retrieve it?




All times are GMT +1. The time now is 03:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com