Private Declare Function GetShortPathNameA Lib "kernel32" _
(ByVal lpszLongPath As String, _ ByVal lpszShortPath As String, _ ByVal cchBuffer As Long) As Long Public Function ShortPath(ByVal LongName As String) As String '------------------------------------------------------------- ' Returns the short (8.3) filename for a given file or path. '------------------------------------------------------------- ' API Declarations: '------------------------------------------------------------- ' MAX_PATH = 260 ' ' Private Declare Function GetShortPathNameA Lib "kernel32" _ ' (ByVal lpszLongPath As String, _ ' ByVal lpszShortPath As String, _ ' ByVal cchBuffer As Long) As Long '------------------------------------------------------------- Dim r As Long Dim sBuffer As String sBuffer = Space$(MAX_PATH) r = GetShortPathNameA(LongName, sBuffer, MAX_PATH) If r Then ShortPath = Left$(sBuffer, r - 1&) End If End Function |