VB and VBA Users Source Code: Returning an short path name (in DOS 8.3 notation)
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Returning an short path name (in DOS 8.3 notation)
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Friday, September 01, 2006
Hits:
4813
Category:
Visual Basic General
Article:
The code below converts a windows path name into a DOS (8.3) short path name. Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal lBuffer As Long) As Long 'Purpose : Converts a windows long path name into a short path name (8.3 format). 'Inputs : sFileName The path to convert. 'Outputs : Converts a windows long path name into a short path name (8.3 format). 'Author : Andrew Baker 'Date : 13/11/2002 10:16 'Example : Debug.Print GetShortPath("C:\Program Files\Microsoft Office\") returns C:\PROGRA~1\MICROS~1\ 'Revisions : Public Function GetShortPath(sFileName As String) As String Dim lEnd As Long, sPath As String 'Create buffer sPath = String$(256, 0) 'Get short pathname lEnd = GetShortPathName(sFileName, sPath, Len(sPath )) 'Return result GetShortPath = Left$(sPath, lEnd) End Function
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder