Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
just file name no path
Hi
is there a way to get the file name only? Using this fileToOpen = Application.GetOpenFilename("DBF Files (*.dbf), *.dbf") i got complete path. i want the path as well as file name. So, for path this is ok to me but not for the file name. Please help me or direct me to the right place. musa.biralo |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
just file name no path
Hi Musa
You can use Dir MsgBox Dir(fileToOpen) -- Regards Ron de Bruin http://www.rondebruin.nl "musa.biralo" wrote in message ups.com... Hi is there a way to get the file name only? Using this fileToOpen = Application.GetOpenFilename("DBF Files (*.dbf), *.dbf") i got complete path. i want the path as well as file name. So, for path this is ok to me but not for the file name. Please help me or direct me to the right place. musa.biralo |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
just file name no path
Var1 = Application.GetOpenFilename("DBF Files (*.dbf), *.dbf")
fileToOpen = Right(Var1, Len(Var1) - InStrRev(Var1,Application.PathSeparator)) Charles Chickering musa.biralo wrote: Hi is there a way to get the file name only? Using this fileToOpen = Application.GetOpenFilename("DBF Files (*.dbf), *.dbf") i got complete path. i want the path as well as file name. So, for path this is ok to me but not for the file name. Please help me or direct me to the right place. musa.biralo |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
just file name no path
If you're using xl2k or higher, you could use instrrev() to find the last \.
dim filetoopen as variant dim JustFileName as string fileToOpen = Application.GetOpenFilename("DBF Files (*.dbf), *.dbf") if filetoopen = false then exit sub end if justfilename = mid(filetoopen,instrrev(filetoopen,"\")+1) "musa.biralo" wrote: Hi is there a way to get the file name only? Using this fileToOpen = Application.GetOpenFilename("DBF Files (*.dbf), *.dbf") i got complete path. i want the path as well as file name. So, for path this is ok to me but not for the file name. Please help me or direct me to the right place. musa.biralo -- Dave Peterson |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
just file name no path
What if they are using a cursed Mac? <gr
-- Charles Chickering "A good example is twice the value of good advice." "Dave Peterson" wrote: If you're using xl2k or higher, you could use instrrev() to find the last \. dim filetoopen as variant dim JustFileName as string fileToOpen = Application.GetOpenFilename("DBF Files (*.dbf), *.dbf") if filetoopen = false then exit sub end if justfilename = mid(filetoopen,instrrev(filetoopen,"\")+1) "musa.biralo" wrote: Hi is there a way to get the file name only? Using this fileToOpen = Application.GetOpenFilename("DBF Files (*.dbf), *.dbf") i got complete path. i want the path as well as file name. So, for path this is ok to me but not for the file name. Please help me or direct me to the right place. musa.biralo -- Dave Peterson |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
just file name no path
If a serious question,
A MAC uses VBA5 and instrrev was introduced with VBA6. The mac is stuck with the properties, methods and functions found in xl97 as far as VBA alone. -- Regards, Tom Ogilvy "Charles Chickering" wrote: What if they are using a cursed Mac? <gr -- Charles Chickering "A good example is twice the value of good advice." "Dave Peterson" wrote: If you're using xl2k or higher, you could use instrrev() to find the last \. dim filetoopen as variant dim JustFileName as string fileToOpen = Application.GetOpenFilename("DBF Files (*.dbf), *.dbf") if filetoopen = false then exit sub end if justfilename = mid(filetoopen,instrrev(filetoopen,"\")+1) "musa.biralo" wrote: Hi is there a way to get the file name only? Using this fileToOpen = Application.GetOpenFilename("DBF Files (*.dbf), *.dbf") i got complete path. i want the path as well as file name. So, for path this is ok to me but not for the file name. Please help me or direct me to the right place. musa.biralo -- Dave Peterson |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
just file name no path
Thank you D_A_D
you just gave me what i was looking for... thank you very much musa.biralo Die_Another_Day wrote: Var1 = Application.GetOpenFilename("DBF Files (*.dbf), *.dbf") fileToOpen = Right(Var1, Len(Var1) - InStrRev(Var1,Application.PathSeparator)) Charles Chickering musa.biralo wrote: Hi is there a way to get the file name only? Using this fileToOpen = Application.GetOpenFilename("DBF Files (*.dbf), *.dbf") i got complete path. i want the path as well as file name. So, for path this is ok to me but not for the file name. Please help me or direct me to the right place. musa.biralo |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
just file name no path
Just to add to Tom's response, I'd loop backwards.
dim iCtr as long dim filetoopen as variant dim JustFileName as string fileToOpen = Application.GetOpenFilename("DBF Files (*.dbf), *.dbf") if filetoopen = false then exit sub end if for ictr = len(filetoopen) to 1 step -1 if mid(filetoopen, ictr, 1) = Application.PathSeparator then justfilename = mid(filetoopen, ictr + 1) exit for end if next ictr Charles Chickering wrote: What if they are using a cursed Mac? <gr -- Charles Chickering "A good example is twice the value of good advice." "Dave Peterson" wrote: If you're using xl2k or higher, you could use instrrev() to find the last \. dim filetoopen as variant dim JustFileName as string fileToOpen = Application.GetOpenFilename("DBF Files (*.dbf), *.dbf") if filetoopen = false then exit sub end if justfilename = mid(filetoopen,instrrev(filetoopen,"\")+1) "musa.biralo" wrote: Hi is there a way to get the file name only? Using this fileToOpen = Application.GetOpenFilename("DBF Files (*.dbf), *.dbf") i got complete path. i want the path as well as file name. So, for path this is ok to me but not for the file name. Please help me or direct me to the right place. musa.biralo -- Dave Peterson -- Dave Peterson |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
just file name no path
Just thought I'd say thanks for this too. I've been looking all
morning for this! Thanks :) Dave Peterson wrote: Just to add to Tom's response, I'd loop backwards. dim iCtr as long dim filetoopen as variant dim JustFileName as string fileToOpen = Application.GetOpenFilename("DBF Files (*.dbf), *.dbf") if filetoopen = false then exit sub end if for ictr = len(filetoopen) to 1 step -1 if mid(filetoopen, ictr, 1) = Application.PathSeparator then justfilename = mid(filetoopen, ictr + 1) exit for end if next ictr Charles Chickering wrote: What if they are using a cursed Mac? <gr -- Charles Chickering "A good example is twice the value of good advice." "Dave Peterson" wrote: If you're using xl2k or higher, you could use instrrev() to find the last \. dim filetoopen as variant dim JustFileName as string fileToOpen = Application.GetOpenFilename("DBF Files (*.dbf), *.dbf") if filetoopen = false then exit sub end if justfilename = mid(filetoopen,instrrev(filetoopen,"\")+1) "musa.biralo" wrote: Hi is there a way to get the file name only? Using this fileToOpen = Application.GetOpenFilename("DBF Files (*.dbf), *.dbf") i got complete path. i want the path as well as file name. So, for path this is ok to me but not for the file name. Please help me or direct me to the right place. musa.biralo -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
File Path Too Long? Not Anymore! Check out Long Path Tool | Excel Discussion (Misc queries) | |||
http://CannotDeleteFile.net - Cannot Delete File? Try Long Path ToolFilename is too long? Computer Complaining Your Filename Is Too Long? TheLong Path Tool Can Help While most people can go about their businessblissfully unaware of the Windo | Excel Discussion (Misc queries) | |||
Formula too long - new file path is shorter than old file path - Excel 2003 | Excel Worksheet Functions | |||
How set file open path to filepath of file opened with Explorer ? | Excel Programming | |||
get path - save new file - same sub-directory as existing file | Excel Programming |