ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Filename as string (https://www.excelbanter.com/excel-programming/341815-re-filename-string.html)

Dr. Stephan Kassanke

Filename as string
 

"Mark" schrieb im Newsbeitrag
...
I am using Excel 97. Can someone please assist me with some code which
gives
me as a string the activeworkbook.name without the ".xls" at the end?

Thanks
--
Mark


Hi Mark,

try left(ActiveWorkbook.Name,len(ActiveWorkbook.Name)-4)

cheers,
Stephan



Stefano Gatto

Filename as string
 
Try InStrRev() and look for the dot, in case the suffix is more or less than
3 characters.
--
Stefano Gatto


"Dr. Stephan Kassanke" wrote:


"Mark" schrieb im Newsbeitrag
...
I am using Excel 97. Can someone please assist me with some code which
gives
me as a string the activeworkbook.name without the ".xls" at the end?

Thanks
--
Mark


Hi Mark,

try left(ActiveWorkbook.Name,len(ActiveWorkbook.Name)-4)

cheers,
Stephan




Cush

Filename as string
 
I don't think InStrRev was around in 97.

"Stefano Gatto" wrote:

Try InStrRev() and look for the dot, in case the suffix is more or less than
3 characters.
--
Stefano Gatto


"Dr. Stephan Kassanke" wrote:


"Mark" schrieb im Newsbeitrag
...
I am using Excel 97. Can someone please assist me with some code which
gives
me as a string the activeworkbook.name without the ".xls" at the end?

Thanks
--
Mark


Hi Mark,

try left(ActiveWorkbook.Name,len(ActiveWorkbook.Name)-4)

cheers,
Stephan




Stefano Gatto

Filename as string
 
Good point!

So do this:

Function strFilenameWithoutExtension(strFilename As String) As String
Dim intPos As Integer
For intPos = Len(strFilename) To 1 Step -1
If Mid(strFilename, intPos, 1) = "." Then
strFilenameWithoutExtension = Mid(strFilename, 1, intPos - 1)
Exit For
End If
Next intPos
End Function

--
Stefano Gatto


"cush" wrote:

I don't think InStrRev was around in 97.

"Stefano Gatto" wrote:

Try InStrRev() and look for the dot, in case the suffix is more or less than
3 characters.
--
Stefano Gatto


"Dr. Stephan Kassanke" wrote:


"Mark" schrieb im Newsbeitrag
...
I am using Excel 97. Can someone please assist me with some code which
gives
me as a string the activeworkbook.name without the ".xls" at the end?

Thanks
--
Mark

Hi Mark,

try left(ActiveWorkbook.Name,len(ActiveWorkbook.Name)-4)

cheers,
Stephan





All times are GMT +1. The time now is 05:45 PM.

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