ShortName

R

Robin Clay

Greetings ! and a Happy New Year !

This works OK:-
For J = 1 To .FoundFiles.Count Step 1
myText = .FoundFiles(J)
....

returning the long file name of each file in turn
But how can I get the SHORT filename of each in turn ?

myText = .FoundFiles(J).ShortName

doesn't work.


Regards

Robin
 
J

JLGWhiz

You could put this in your standard module.

Sub ShowShortName(filespec)
Dim fs, f, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(filespec)
s = "The short name for " & "" & UCase(f.Name)
s = s & "" & vbCrLf
s = s & "is: " & "" & f.ShortName & ""
MsgBox s, 0, "Short Name Info"
End Sub

Then use it like a Function to display a pop up message:

Sub shw()
ShowShortName(MyText)
End Sub
 
R

Robin Clay

Bravo !

Here's what I used:-

Function ShortName(filespec)
Dim fs, f, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(filespec)
ShortName = f.ShortName
End Function

.... and then in my main routine:-
For J = 1 To .FoundFiles.Count Step 1
myText = ShortName(.FoundFiles(J))
etc.

Thank you very much indeed.


Regards

Robin
 
Top