Split fullname into Drive, Path and Filename

  • Thread starter Thread starter Michael Göhring
  • Start date Start date
M

Michael Göhring

Hello all,

I need to split up the Fullname of my workbook into Drive, Path, filename;
and to check, if drive is a network share then to change the Drive to UNC.

How can I achieve this in Excel ?

Thanks in Advance

Michael
 
Not exactly as requested - but produces the required results (?)
'-----------------------------------------------------------------
Dim MyBookName As String
Dim MyPath As String
Dim MyDrive As String
'----------------------
MyBookName = ActiveWorkbook.Name
MyPath = ActiveWorkbook.Path
MyDrive = Left(MyPath, 2)
MsgBox (MyDrive & vbCr & MyPath & vbCr & MyBookName)
'-----------------------------------------------------------------------
 
if your code will only be used on xl2000 or later, you can use the split
command

varr = split(Thisworkbook.fullname,"\")

This will give you a zero based array with each section of the fullname in a
separate array element. Each folder will be in a separate element as well.

If all you want to do is replace the drive letter with the UNC reference,
you can probably just test if the second- third characters are a ":\" and
if so, replace the drive letter with the UNC reference.
Mid(thisworkbook.path,2,2)
 
Back
Top