Trim path from full filename
I'm sure there's some resevred word for getting just the file name
But in the meantime, here's another solution
Using the variable that captures the whole file path and file name, read it backwards a character at a time until the program finds the first slash ( \ ). Stop there, and you have your file name
Public sub Get_A_FileNam
File_Name = (Full_Path_with_File_Name - Full Path) ' assuming this actually gets the file path & name..
for a = len(File_Name) to 1 step -
if right(left(File_Name,a),1) = "\" the
msgbox("Your file name is " & right(File_Name,len(File_Name)-a)
exit fo
end i
next a
End Su
This code is untested, but feel free to try it out
Ti
----- Arawn wrote: ----
I have a part of a macro that I need some help with
I have the code that is returning the full file path, and then th
full file path with the filename, but I want to simply return th
filename for use in other coding
Basically what I want is
File_Name = (Full_Path_with_File_Name - Full Path
However, I dont know how to go about this. Both the file name an
pathing will be variable, with varying lengths and names
I'm using Excel 2003, if that makes a difference
Thanks
~Araw
|