Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 272
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
File Path Too Long? Not Anymore! Check out Long Path Tool Max Loger Excel Discussion (Misc queries) 1 March 24th 17 07:59 AM
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 Max Loger Excel Discussion (Misc queries) 0 June 14th 11 04:30 PM
Formula too long - new file path is shorter than old file path - Excel 2003 Greg J Excel Worksheet Functions 1 November 22nd 06 05:16 PM
How set file open path to filepath of file opened with Explorer ? RandyDtg1 Excel Programming 0 May 14th 04 02:05 AM
get path - save new file - same sub-directory as existing file tegger Excel Programming 2 October 21st 03 10:45 AM


All times are GMT +1. The time now is 08:51 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"