Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 367
Default 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?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 253
Default 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?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"