
Convert Long Path to Short
Ooh - I got beaten to it with a solution that I never expected!
Damn - and there goes my bet that it was only possible through a custom DLL - I suppose the FSO could be construed as such a thing?
Regards,
Chris.
There is only one problem with the function below. The file must already exist as strLongPath in order for it to work :P
MsgBox ShortPath("C:\Program Files\Temp Files\Order Processing\MyFile.txt")
Function ShortPath(ByVal strLongPath)
Dim objFs
Dim objFile
'
' Create the Scripting.FileSystemObject object.
'
Set objFs = CreateObject("Scripting.FileSystemObject")
'
' Open the file.
'
Set objFile = objFs.GetFile(strLongPath)
'
' Retrieve and return the short path.
'
ShortPath = objFile.shortName()
'
' Destroy the file system objects.
'
Set objFile = Nothing
Set objFs = Nothing
End Function
Mythran