![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Feb 2002
Posts: 6
|
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 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Short_name = "Input File"
Long_name = Short_name & ".xls" Cheers, Nate |
|
|
|
|
|
#3 |
|
New Member
Join Date: Feb 2002
Posts: 6
|
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 |
|
Board Regular
Join Date: Feb 2002
Posts: 74
|
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 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
How about this:
Short_Name = worksheetfunction.substitute(full_name,".xls","") Cheers, Nate |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|