Extract File Name from ahtCommonFileOpenSave command

I am using the function below and it works perfectly.  Is there a way I can strip out just the filename from the results.

For example C:\Backupofwork\Work\CMD\Database\Payments.xls is returned but I will like to extract "Payments.xls" from the string.

Is this possible?

    strStartDir = CurrentDb.Name
    strStartDir = Left(strStartDir, Len(strStartDir) - Len(Dir(strStartDir)))

   
    strFilter = ahtAddFilterItem(strFilter, _
                        "Excel Files (*.xls)", "*.xls")
    Me.txtFileName = ahtCommonFileOpenSave(InitialDir:=strStartDir, _
                     Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
                     DialogTitle:="Select File")
RDLFCAsked:
Who is Participating?
 
Rey Obrero (Capricorn1)Commented:
dim fileName as string

strStartDir = CurrentDb.Name
    strStartDir = Left(strStartDir, Len(strStartDir) - Len(Dir(strStartDir)))

   
    strFilter = ahtAddFilterItem(strFilter, _
                        "Excel Files (*.xls)", "*.xls")
    Me.txtFileName = ahtCommonFileOpenSave(InitialDir:=strStartDir, _
                     Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
                     DialogTitle:="Select File")
    fileName=mid(Me.txtFileName,Instrrev(Me.txtFileName,"\")+1)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.