Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Name problem 1

Status
Not open for further replies.

65321

Programmer
Aug 20, 2001
8
SY
how can i get the 8:3 name from the application name
eg : i have this path
"C:\Program Files\Common Files\Myprogram.Exe"

and i want a function to change it to the path :
"C:\progra~1\common~1\Myprog~1.Exe"

thank u ..............
 
Hi,

Try this please


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


Hope this helps
 
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

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top