Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default File extension

I am trying to extract the file extension from an excel filepath, in order
to check for .xlsx .xlsm and .xls - for Excel 2003 and 2007.

What I would like to do is to have a message box pop up on the sheet
"FileExtension" saying something like:-

MsgBox "The file extension for this file is " & FileExt

This would preferably be in the Worksheet_Activate() procedure.

Thanks
Sandy

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 146
Default File extension

Try this

Dim fileExtension as String
Dim splitArray() As String
splitArray = Split(ThisWorkbook.name, ".")
fileExtension = splitArray(UBound(splitArray))

3rd line, Splits up a String, using the . character as where to split it so
Aworkbook.xls gets split into two.

4th line - assigns the variable fileExtension to the last element in the
array, which will be the extension.

Hope that makes sense.

2nd line - Split up a String,

"Sandy" wrote:

I am trying to extract the file extension from an excel filepath, in order
to check for .xlsx .xlsm and .xls - for Excel 2003 and 2007.

What I would like to do is to have a message box pop up on the sheet
"FileExtension" saying something like:-

MsgBox "The file extension for this file is " & FileExt

This would preferably be in the Worksheet_Activate() procedure.

Thanks
Sandy

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default File extension

Thank you very much - works perfectly
Sandy

"NateBuckley" wrote in message
...
Try this

Dim fileExtension as String
Dim splitArray() As String
splitArray = Split(ThisWorkbook.name, ".")
fileExtension = splitArray(UBound(splitArray))

3rd line, Splits up a String, using the . character as where to split it
so
Aworkbook.xls gets split into two.

4th line - assigns the variable fileExtension to the last element in the
array, which will be the extension.

Hope that makes sense.

2nd line - Split up a String,

"Sandy" wrote:

I am trying to extract the file extension from an excel filepath, in
order
to check for .xlsx .xlsm and .xls - for Excel 2003 and 2007.

What I would like to do is to have a message box pop up on the sheet
"FileExtension" saying something like:-

MsgBox "The file extension for this file is " & FileExt

This would preferably be in the Worksheet_Activate() procedure.

Thanks
Sandy

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
Display file name without the file type extension NAHolmes Excel Worksheet Functions 5 November 23rd 09 05:54 PM
Determine Excel file version with no file extension. tjlumpkin Excel Discussion (Misc queries) 2 July 23rd 09 06:59 AM
file format or file extension is not valid...error message Ballun Excel Discussion (Misc queries) 0 May 7th 09 09:06 PM
Additional file with no extension created during File Save As proc Peter Rooney Excel Discussion (Misc queries) 2 August 11th 05 02:48 PM
I need to download an exel spreadsheet file. (file extension :xls) buckrogers Excel Discussion (Misc queries) 2 December 8th 04 11:08 PM


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