How to get filename without the extention
Find bottlenecks in your Excel workbooks
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 5 of 5

Thread: How to get filename without the extention

  1. #1
    New Member
    Join Date
    Feb 2002
    Posts
    6
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    In a macro how can I assign to a variable only the file name not including the extention?
    ie. full_name = "InputFile.xls"
    I want Short_name to be "InputFile"
    Thx.

  2. #2
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Short_name = "Input File"
    Long_name = Short_name & ".xls"

    Cheers, Nate

  3. #3
    New Member
    Join Date
    Feb 2002
    Posts
    6
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    The problem is the reverse. I have the full file name from ThisWorkBook.Name procedure but I can't just extract the shorten form.
    Thx.

  4. #4
    Board Regular
    Join Date
    Feb 2002
    Posts
    75
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Here's one way to do this:

    full_Name = ThisWorkbook.Name
    If (Right(full_Name,4) Like ".???") then
    Short_Name = Left(full_Name, Len(full_Name)-4)
    Else
    Short_Name = full_Name
    End If
    "Interfere? Of course we should interfere! Always do what you're best at, that's what I say!" -- The Doctor, Nightmare of Eden

  5. #5
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    How about this:

    Short_Name = worksheetfunction.substitute(full_name,".xls","")

    Cheers, Nate

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com