Dim Name As String
Dim Ext As String
If Len(ProgramName) > 12 Then
Name = Left(ProgramName, 6)
Ext = Right(ProgramName, 4)
ProgramName= Name & "~1" & Ext
End If
I'm afraid that Imhoteb's answer is less than sufficient. It'll have problems with file names with no extension (eg folders), and give you the same short name for different files that happen to have the same first 6 characters.
You can solve this with some API calls, or use of the FileSystemObject. Here is an example function that should kick you off in the right direction: [tt]
Public Function GetShortName(strFile As String) As String
Dim fso As Object
Set fso = CreateObject("scripting.filesystemobject" ' Use the following line if you want the short name of a folder
' instead of a file
' GetShortName = fso.GetFile(strFile).ShortName GetShortName = fso.GetFile(strFile).ShortName
End Function
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.