ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Split fullname into Drive, Path and Filename (https://www.excelbanter.com/excel-programming/285257-split-fullname-into-drive-path-filename.html)

Michael Göhring

Split fullname into Drive, Path and Filename
 
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



BrianB

Split fullname into Drive, Path and Filename
 
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)
'-----------------------------------------------------------------------


---
Message posted from http://www.ExcelForum.com/


Tom Ogilvy

Split fullname into Drive, Path and Filename
 
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)

--
Regards,
Tom Ogilvy

"Michael Göhring" wrote in message
...
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






All times are GMT +1. The time now is 06:25 PM.

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