File Extension Extraction in VBA

Solved
Tessel75 -  
 Maurice -
Hello,
Is there an expression in Excel VBA that allows extracting the file extension, similar to "name" or "path"?
I've created a small function to achieve this result, but if such an expression existed, I would be much more satisfied.
Thank you for your responses

Configuration: Windows 7 / Firefox 31.0

3 answers

  1. eriiic Posted messages 24581 Registration date   Status Contributor Last intervention   7 281
     
    Hello,

    to my knowledge no.
    One way to do it:
    ext=Mid(nomFich, InstrRev(nomFich, ".") + 1)


    eric

    --
    By continuously trying, we eventually succeed.
    So the more it fails, the more chances we have that it will work. (the Shadoks)
    In addition to the thank you (yes, it is done!!!), remember to mark it as solved. Thank you
    1
  2. Tessel75
     
    Thank you for your response.
    I arrived at the same expression, except that I went through Right() and used intermediate parameters; yours is more streamlined.
    Good night.
    0
  3. Maurice
     
    Hello

    Here is the name or extension

    Sub Test4()
    FileName = "L001000_M_pb69.3656_100.5572_E12.txt"
    File = Mid(FileName, 1, InStrRev(FileName, ".") - 1)
    FileExt = Mid(FileName, InStrRev(FileName, ".") + 1)
    End Sub

    See you

    Maurice
    0