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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Triming path to get exe file

Status
Not open for further replies.

hadacon

Technical User
Feb 13, 2007
30
SA
Hi,
How to trim application exe from path shown in the common dialog.

Filename = c:\programFiles\Accounts\ac.ex

how to trim to get Filename = ac.exe

with best regards,
Hadacon

 
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.

Regards,

Patrick
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top