Palabras clave: carpeta, directorio, fichero, archivo, nombre, corto, largo API
Autor: Happy
Extraído de: Access y VBA
Objetivo:
Rescato estos procedimientos de Happy para obtener el nombre corto de fichero a partir del nombre largo y viceversa.
En un módulo independiente:
Option Compare Database
Option Explicit
Private Declare Function GetLongPathName Lib "kernel32" _
Alias "GetLongPathNameA" _
(ByVal lpszShortPath As String, _
ByVal lpszLongPath As String, _
ByVal cchBuffer As Long) As Long
Private Declare Function GetShortPathName Lib "kernel32" _
Alias "GetShortPathNameA" _
(ByVal lpszLongPath As String, _
ByVal lpszShortPath As String, _
ByVal lBuffer As Long) As Long
Function GetLongName(ShortPath As String) As String
Dim LenLongName As Long
Dim buffer As String * 1000
LenLongName = GetLongPathName(ShortPath, _
buffer, Len(buffer))
If LenLongName Then
GetLongName = Left$(buffer, LenLongName)
End If
End Function
Function GetShortName(LongPath As String) As String
Dim LenShortName As Long
Dim buffer As String * 1000
LenShortName = GetShortPathName(LongPath, _
buffer, Len(LongPath))
If LenShortName Then
GetShortName = Left$(buffer, LenShortName)
End If
End Function