RE: Is there an object property that will return the file type?
- From: cla99009 <cla99009@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 18 Aug 2008 15:37:00 -0700
Thanks for the pointers.
The mid function doesn't work because if a new workbook hasn't been saved
yet, it doesn't have a file type extension, which would cause an error in the
macro. I ended up using If Right(ActiveWorkbook.Name, 3) <> "csv" Then Exit
Sub
It works just fine now, no errors, no messes.
"JMB" wrote:
On the off chance someone uses a period in the filename (eg.
File.Name.Extension), the OP might also consider using InStrRev
BookName = ThisWorkbook.Name
Booktype = Mid(BookName, InStrRev(BookName, ".") + 1)
"Joel" wrote:
BookName = ThisWorkbook.Name
Booktype = Mid(BookName, InStr(BookName, ".") + 1)
"cla99009" wrote:
I'm writing a formatting macro that I only want to run on .txt or .csv files.
This mostly a safety feature for other users so if they accidentally press
the wrong combo of hot keys they don't have a macro run that will ruin the
spread*** they are currently working on.
Is there an object property I can write into the code that will return the
file type of the active workbook?
ActiveWorkbook.FileType doesn't work.
- Follow-Ups:
- References:
- Prev by Date: Re: highlights cells that are not a dependents
- Next by Date: Add-in Already Open
- Previous by thread: RE: Is there an object property that will return the file type?
- Next by thread: RE: Is there an object property that will return the file type?
- Index(es):