removing the file extention

R

Rick Rothstein

If the filename also has its path with it...

FileNameOnly = Mid(Left(PathAndFilename, InStrRev(PathAndFilename, _
".") - 1), InStrRev(PathAndFilename, "\") + 1)

If the filename is by itself (that is, without its path)...

FileNameOnly = Left(FilenameAndExtension, _
InStrRev(PathAndFilename, ".") - 1)
 
S

Scoops

Is there an easy way of removing the file extention from the file name?

Hi Fan

Sub StripExt()
Dim str_FileName As String

str_FileName = Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4)

End Sub

Regards

Steve
 
R

Rick Rothstein

Your statement may not work for the OP... file extensions are not always
only three characters long. Some examples from the Office 12 (Office 2007)
directory... ExpenseReport.xltx, excel.exe.manifest, SOLVER.XLAM, Building
Blocks.dotx, NewFileItems.vsdir, etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top