Tuesday, March 24, 2009

Remove File Extension


Function RemoveExtension (strName As String)
RemoveExtension = Left (strName, Instr(strName, ".")-1)
End Function

1 comment:

  1. This one is more general:

    Function RemoveFileExtension(path As String) As String
    Dim table As Variant
    Dim fileName As String
    fileName = path
    If InStr(fileName, "\") > 0 Then
    table = Split(Trim(fileName), "\")
    fileName = table(UBound(table))
    End If
    If InStr(fileName, ".") > 0 Then
    table = Split(fileName, ".")
    RemoveFileExtension = Left(path, Len(path) - Len(table(UBound(table))) - 1)
    Else
    RemoveFileExtension = path
    End If
    End Function

    ReplyDelete

Note: Only a member of this blog may post a comment.