ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   just file name no path (https://www.excelbanter.com/excel-programming/373019-just-file-name-no-path.html)

musa.biralo

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


Ron de Bruin

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




Die_Another_Day

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



Dave Peterson

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

Charles Chickering

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


Tom Ogilvy

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


musa.biralo

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



Dave Peterson

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

[email protected]

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




All times are GMT +1. The time now is 02:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com