Visual Basic Programming Code Examples Visual Basic > Files Directories Drives Code Examples Get the Short Path Name Get the Short Path Name There comes a time when you just don't want a long file name. I myself had experienced some problems with my midi code because it wasn't working with long filenames. All you need to do is pass the long file name to the GetShortPathName API and it will return the short name. Place this code in a .bas module Option Explicit Public Declare Function GetShortPathName Lib "kernel32" _ Alias "GetShortPathNameA" _ (ByVal lpszLongPath As String, _ ByVal lpszShortPath As String, _ ByVal cchBuffer As Long) As Long Public Function GetShortName(sFile As String) As String Dim sShortFile As String * 67 Dim lResult As Long 'Make a call to the GetShortPathName API lResult = GetShortPathName(sFile, sShortFile, _ Len(sShortFile)) 'Trim out unused characters from the string. GetShortName = Left$(sShortFile, lResult) End Function Now place this code in the Form_Load event Private Sub Form_Load() Debug.Print GetShortName(App.Path) End Sub