Automatic filename


Posted by Joe Garza on October 16, 2001 11:31 AM

Do you know of a way, other than =CELL("Filename"), to have the name of the file show up in a cell. The =CELL("filename") gives the whole path, and I dont want that - just the name of the file.

Thanks

Posted by IML on October 16, 2001 11:35 AM

If you have cell filename in A1, you could use
=MID(A1,FIND("[",A1)+1,FIND("]",A1)-FIND("[",A1)-1)

or all in one cell with
=MID(CELL("filename"),FIND("[",CELL("filename"))+1,FIND("]",CELL("filename"))-FIND("[",CELL("filename"))-1)

good luck

Posted by Aladin Akyurek on October 16, 2001 11:49 AM

Ian & Joe,

Gyula Lorant has proposed to use a named formula to do the task as reply to Joe's first post. I think Joe misundurstood it. The proposal requires that

you activate Insert|Name|Define;
you enter a name e.g., Doc as suggested by Gyula in the Names in Workbook box;
you enter in the Refers To box the formula:

=GET.DOCUMENT(88)

then just click OK.

Now activate any cell in any worksheet within the workbook and type

=Doc

This will produce the name of the workbook or file as Joe wants and as Ian's formula will compute.

PS. The workbook must have a filename (that is, it must have been saved at least once) for both Gyula's and Ian's formulas to work.

Aladin

=========

Posted by IML on October 16, 2001 2:30 PM

That's real slick - I didn't see the earlier post (nt)

Posted by Gyula Lorant on October 16, 2001 7:27 PM

Small correction .....

Re : "The workbook must have a filename (that is, it must have been saved at least once) for both Gyula's and Ian's formulas to work"

For my suggested method to work, it is not necessary to have saved the workbook first - it will work even on a new workbook that has not been saved.



Posted by Gyula Lorant on October 16, 2001 7:31 PM

But .....

It is necessary to re-enter the cell formula whenever the workbook is re-named (could be done automatically via a simple Worksheet_SelectionChange procedure).