PC Review


Reply
Thread Tools Rate Thread

How do I GetCurrentDirectory in Excel?

 
 
Thunderbolt2000
Guest
Posts: n/a
 
      18th Jan 2008
I need to retrieve the current drive letter to use in my Excel spreadsheet,
how do I retrieve it?
 
Reply With Quote
 
 
 
 
carlo
Guest
Posts: n/a
 
      18th Jan 2008
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
<Thunderbolt2...@discussions.microsoft.com> wrote:
> I need to retrieve the current drive letter to use in my Excel spreadsheet,
> how do I retrieve it?


 
Reply With Quote
 
Jean-Yves
Guest
Posts: n/a
 
      18th Jan 2008
Hi,
try msgbox CurDir

Regards
JY

"Thunderbolt2000" <(E-Mail Removed)> wrote in
message news:E329A952-5022-4C48-B226-(E-Mail Removed)...
>I need to retrieve the current drive letter to use in my Excel spreadsheet,
> how do I retrieve it?



 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      18th Jan 2008
"carlo" <(E-Mail Removed)> 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" <(E-Mail Removed)> wrote in message
news:834afa11-a96b-4fa0-bd7d-(E-Mail Removed)...
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
<Thunderbolt2...@discussions.microsoft.com> wrote:
> I need to retrieve the current drive letter to use in my Excel
> spreadsheet,
> how do I retrieve it?


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
another question - GetCurrentDirectory Matthias Heise Microsoft Dot NET Compact Framework 2 25th Apr 2005 03:55 PM
GetCurrentDirectory in CF Robert Hanson Microsoft Dot NET Compact Framework 5 13th May 2004 03:52 PM
Directory.GetCurrentDirectory Zanna Microsoft Dot NET Compact Framework 6 10th Feb 2004 11:08 PM
getcurrentdirectory poppy Microsoft ASP .NET 2 16th Oct 2003 09:29 AM
GetCurrentDirectory? Dan Microsoft C# .NET 6 10th Sep 2003 03:18 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:55 PM.