You can get this info easily using the FileSystemObject:
Code:
Dim fs As FileSystemObject
Dim sFilename As String
'//
Set fs = New FileSystemObject
'//
sFilename = fs.GetFileName("c:\programFiles\Accounts\ac.ex")
'//
Debug.Print sFilename
Make sure you have a reference to Microsoft Scripting Runtime to use this.
If you don't want the overhead of Srcipting runtime then you could use the classic string handling functions InStrRev and Mid$
Code:
myFile = Mid$(myStr, InStrRev(myStr, "\") + 1)
___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?' Drive a Steam Roller Steam Engine Prints
If you're using the commondialog just use FileTitle instead of FileName, that'll give you what you're after.
Hope this helps
HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
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.