ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Referencing the file type (https://www.excelbanter.com/excel-discussion-misc-queries/225600-referencing-file-type.html)

EvilTony

Referencing the file type
 
Hi,

Is it possoble for an Excel cell to 'know' what type of file it belongs to?

In other words, if a file is a template (ABC.xlt), can I display one value,
and if it has been saved as a workbook (ABC.xls) can I display a different
value?

I need to show/hide a prompt to save the file as a workbook after a change
has been made to the template.

--
It''s a little fit bunny, this feeling inside

Gary''s Student

Referencing the file type
 
There is probably an easier way, but in C1 enter:

=CELL("filename",A1)
this will display something like:

C:\Documents and Settings\Owner\Favorites\Links\e\spreads\[sendkey
experiment.xls]Sheet1

Note the extension is buried in there. The in another cell:

=IF(LEN(C1)=LEN(SUBSTITUTE(C1,"xls","")),"not xls","xls")
--
Gary''s Student - gsnu200841


"EvilTony" wrote:

Hi,

Is it possoble for an Excel cell to 'know' what type of file it belongs to?

In other words, if a file is a template (ABC.xlt), can I display one value,
and if it has been saved as a workbook (ABC.xls) can I display a different
value?

I need to show/hide a prompt to save the file as a workbook after a change
has been made to the template.

--
It''s a little fit bunny, this feeling inside


OssieMac

Referencing the file type
 
The following will return xls or xlt or Unknown Type if it is neither xls or
xlt. Note that it is one line although it breaks in this post

=IF(ISERROR(FIND(".xls]",CELL("Filename"),1)),IF(ISERROR(FIND(".xlt]",CELL("Filename"),1)),"Unknown Type","xlt"),"xls")

You can replace "Unknown Type" with "" to return a blank for neither xls or
xlt.

--
Regards,

OssieMac


"EvilTony" wrote:

Hi,

Is it possoble for an Excel cell to 'know' what type of file it belongs to?

In other words, if a file is a template (ABC.xlt), can I display one value,
and if it has been saved as a workbook (ABC.xls) can I display a different
value?

I need to show/hide a prompt to save the file as a workbook after a change
has been made to the template.

--
It''s a little fit bunny, this feeling inside


EvilTony

Referencing the file type
 
Thanks Gary's Student... that is perfect.

It appears that the filename of a template is blank until it is saved, which
is as informative for my purpose as if it had a name.


--
It''''s a little fit bunny, this feeling inside


"Gary''s Student" wrote:

There is probably an easier way, but in C1 enter:

=CELL("filename",A1)
this will display something like:

C:\Documents and Settings\Owner\Favorites\Links\e\spreads\[sendkey
experiment.xls]Sheet1

Note the extension is buried in there. The in another cell:

=IF(LEN(C1)=LEN(SUBSTITUTE(C1,"xls","")),"not xls","xls")
--
Gary''s Student - gsnu200841


"EvilTony" wrote:

Hi,

Is it possoble for an Excel cell to 'know' what type of file it belongs to?

In other words, if a file is a template (ABC.xlt), can I display one value,
and if it has been saved as a workbook (ABC.xls) can I display a different
value?

I need to show/hide a prompt to save the file as a workbook after a change
has been made to the template.

--
It''s a little fit bunny, this feeling inside


Dave Peterson

Referencing the file type
 
If you're using code, you can check the .path of the workbook.

If activeworkbook.path = "" then
'never been saved
else
'saved at least once
end if

EvilTony wrote:

Thanks Gary's Student... that is perfect.

It appears that the filename of a template is blank until it is saved, which
is as informative for my purpose as if it had a name.

--
It''''s a little fit bunny, this feeling inside

"Gary''s Student" wrote:

There is probably an easier way, but in C1 enter:

=CELL("filename",A1)
this will display something like:

C:\Documents and Settings\Owner\Favorites\Links\e\spreads\[sendkey
experiment.xls]Sheet1

Note the extension is buried in there. The in another cell:

=IF(LEN(C1)=LEN(SUBSTITUTE(C1,"xls","")),"not xls","xls")
--
Gary''s Student - gsnu200841


"EvilTony" wrote:

Hi,

Is it possoble for an Excel cell to 'know' what type of file it belongs to?

In other words, if a file is a template (ABC.xlt), can I display one value,
and if it has been saved as a workbook (ABC.xls) can I display a different
value?

I need to show/hide a prompt to save the file as a workbook after a change
has been made to the template.

--
It''s a little fit bunny, this feeling inside


--

Dave Peterson


All times are GMT +1. The time now is 08:35 AM.

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