ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Overwrite / Append files? (https://www.excelbanter.com/excel-discussion-misc-queries/108095-overwrite-append-files.html)

Aidan Engineer

Overwrite / Append files?
 
At present every time I run my software package the output file overwrites
the previous one (as they have the same name). Is there any way of setting up
my folder so that instead of overwriting the previous file the new file gets
a number appended to it, hence keeping both the new and previous file.
i.e. previous file name = test
new file name = test(1)
etc..

Any help would be greatly appreciated.

Allllen

Overwrite / Append files?
 
Can you post the code which is currently doing this output? Is it in Excel?
My "easiest way" would be to get this output file to be written with the
date and time as part of its name.

Here is a useful post from Dave Peterson only a few days ago.

************
I think I'd use the time and date. It makes your code easier and even allows
you to know when the save took place based on the filename itself.

dim myFileName as string
with activeworkbook
myfilename = left(.fullname,len(.fullname)-4) & _
"_" & format(now,"yyyymmdd_hhmmss") & ".xls"

.savecopyas myfilename
end with

chrismusic79 wrote:

I am trying to create a backup file using an autoexec macro, but am
unable to find the command to put in the macro to create the file name.

I need to have the file name auto-incremental depending on what name is
in the folder.

Could anyone also tell me how to create the file name as the current
date..

Thanks.


--

Dave Peterson
**************



--
Allllen


"Aidan Engineer" wrote:

At present every time I run my software package the output file overwrites
the previous one (as they have the same name). Is there any way of setting up
my folder so that instead of overwriting the previous file the new file gets
a number appended to it, hence keeping both the new and previous file.
i.e. previous file name = test
new file name = test(1)
etc..

Any help would be greatly appreciated.


Ron de Bruin

Overwrite / Append files?
 
Make a backup of the folder with a date time stamp is a option
http://www.rondebruin.nl/folder.htm

Try

Sub Copy_Folder()

And use this in the code

'If you want to create a backup of your folder every time you run this macro
'you can create a unique folder with a Date/Time stamp.
'ToPath = "C:\" & Format(Now, "dd-mmm-yy h-mm-ss")


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Aidan Engineer" wrote in message
...
At present every time I run my software package the output file overwrites
the previous one (as they have the same name). Is there any way of setting up
my folder so that instead of overwriting the previous file the new file gets
a number appended to it, hence keeping both the new and previous file.
i.e. previous file name = test
new file name = test(1)
etc..

Any help would be greatly appreciated.





All times are GMT +1. The time now is 10:09 AM.

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