VB and VBA Users Source Code: Returning a file extension from a file name
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Returning a file extension from a file name
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Tuesday, May 28, 2002
Hits:
778
Category:
Files/Directories/IO
Article:
The following routine returns the file extension for a specified file name. 'Purpose : Returns the file type/extension for a give file name. 'Inputs : sFileName The name of the file to return the extension of. 'Outputs : Returns the file type/extension for a give file name. 'Author : Andrew Baker 'Date : 25/03/2001 'Notes : Function FileExtension(sFileName As String) As String Dim lPos As Long lPos = InStrRev(sFileName, ".") If lPos Then 'Found dot, return filetype FileExtension = Mid$(sFileName, lPos + 1) End If Exit Function ErrFailed: Debug.Print "Error in FileExtension: " & Err.Description Debug.Assert False End Function
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder