View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Variable File Name

You can use the Split97 function for this if it must work in Excel 97-2003
See the example I use in this Zip sub to get the file name
http://www.rondebruin.nl/zip.htm

See the VBA help for Split if you use 2000 or higher



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Trevor" wrote in message ...
We are using -

FileOpenName = Application.GetOpenFilename("Text Files
(*.txt),*.txt", 1, "Open IFCAP Text File", , False)

to prompt the user for the file to be opened. Later in our
macro we want to switch from another workbook to this
workbook, but can't figure out how to get the workbook
name as a variable from the FileOpenName variable.

The FileOpenName could be "C:\FOLDER1\FOLDER2\FNAME.xls."
It could have multiple folders and the filename can vary.
We can not see how to get the FNAME.xls extracted. We
looked at Instr but couldn't see how to use it to get what
we want.

Any ideas?