Saving file with name derived from cell contents. (1 Viewer)

niallc

New member
Local time
Today, 08:53
Joined
Apr 18, 2007
Messages
5
I need to save data from a sheet as a tab delimited.txt file for exporting to another dept.

Currently i "Save As" ; Type filename in quotes eg todays file was "Pos.txt.20070417" ;and save as type Tab delimited.
The format of "Pos.txt.YYYYMMDD" is forced upon me.

Cell A2 of the file today contains the data '200704170001'

Is there anyway to write a macro that will do the naming from the contents of CellA2 and the file type selection so the only thing I have to do is save it in the correct directory ?

Thanks from a complete newbie
 

unmarkedhelicopter

Registered User.
Local time
Today, 08:53
Joined
Apr 23, 2007
Messages
177
You have two problems here.
1. You can't save an Excel sheet with a "20070423" type extension
2. Once you have saved the file as a text file (it saves as say :- "Pos.txt.20070423.txt") you then can't rename it without closing the file.

It would be so much easier if you wanted (say) :- Pos.20071423.txt

So the only way to get this to work (as I can see) would be :-
1. Write the macro into your personal macro workbook with a feeder stub in your template or what ever you use to generate your sheet.
2. Run the beforesave code which asks you if you wish to save as ???
3. Save as (say) Pos.txt.20071423.txt
4. Close that sheet
5. Rename that sheet in VBA to Pos.txt.20071423
6. Accept any errors generated if that file already exists
 

Users who are viewing this thread

Top Bottom