ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Return Filename (https://www.excelbanter.com/excel-programming/407042-return-filename.html)

Jarle

Return Filename
 
I have the string that includes path and filename:

C:\Documents and Settings\Folder1\Folder2\....\filename

How can I easily load only the filename to the variable f_name?

rgds
Jarle



IanKR

Return Filename
 
I have the string that includes path and filename:

C:\Documents and Settings\Folder1\Folder2\....\filename

How can I easily load only the filename to the variable f_name?


What you've got there is ThisWorkbook.FullName. To get just the file name
use ThisWorkbook.Name and assign that to f_name.



Bob Phillips

Return Filename
 
If you need to parse it, look at InstrRev in VBA help.

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Jarle" wrote in message
...
I have the string that includes path and filename:

C:\Documents and Settings\Folder1\Folder2\....\filename

How can I easily load only the filename to the variable f_name?

rgds
Jarle





Jarle

Return Filename
 
I did it like this:

s = "C:\Documents and Settings\folder1\folder2\bok2.xls"
s1 = Split(s, "\")
f_name = s1(UBound(s1))


Jarle skrev:

I have the string that includes path and filename:

C:\Documents and Settings\Folder1\Folder2\....\filename

How can I easily load only the filename to the variable f_name?

rgds
Jarle




All times are GMT +1. The time now is 10:15 AM.

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