Home All Groups Group Topic Archive Search About

How do I get just the file name rather than the entire apath

Author
22 Mar 2006 5:04 AM
Joy2006
If I use commondialog1.FileName, I get the entire path along with the
file name. How do I get just the file name?

Author
22 Mar 2006 8:20 AM
J French
On 21 Mar 2006 21:04:32 -0800, "Joy2006" <shubh***@gmail.com> wrote:

>If I use commondialog1.FileName, I get the entire path along with the
>file name. How do I get just the file name?

' ##############################################
'
'  C:\DEV\USLIB\USLIB.BAS  --> USLIB.BAS
'
Function ExtractFileName$(Fle$)

    Dim L9%

    ExtractFileName$ = Fle$        ' 30/8/02 JF
    For L9 = Len(Fle$) To 1 Step -1
        If InStr(":\", Mid$(Fle$, L9, 1)) Then
           ExtractFileName$ = Mid$(Fle$, L9 + 1)
           L9 = 1
        End If
    Next

End Function
Author
22 Mar 2006 2:23 PM
Jeff Johnson [MVP: VB]
"Joy2006" <shubh***@gmail.com> wrote in message
news:1143003871.920323.138970@e56g2000cwe.googlegroups.com...

> If I use commondialog1.FileName, I get the entire path along with the
> file name. How do I get just the file name?

FileTitle