Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 238
Default removing the file extention

Is there an easy way of removing the file extention from the file name?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default removing the file extention

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)

--
Rick (MVP - Excel)


"Fan924" wrote in message
...
Is there an easy way of removing the file extention from the file name?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default removing the file extention

On 9 Dec, 14:31, Fan924 wrote:
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
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default removing the file extention


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.

--
Rick (MVP - Excel)


"Scoops" wrote in message
...
On 9 Dec, 14:31, Fan924 wrote:
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


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
Excel XLW file extention M&M Excel Discussion (Misc queries) 1 July 27th 09 04:50 AM
How can I turn on or off for backup file with XLK extention? Excel Learner Excel Discussion (Misc queries) 1 June 11th 09 03:21 AM
file extention .xsls David Setting up and Configuration of Excel 3 November 13th 07 10:22 PM
changing file extention names David Excel Discussion (Misc queries) 1 November 9th 07 02:41 AM
Problem w/ open no extention file Cam Hua Excel Programming 2 October 27th 04 10:24 PM


All times are GMT +1. The time now is 06:13 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"