Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Date + Filename using save copy as

I need to save a copy of a file each day the macro runs to a network
location. What is an easy way to code it to append the date to the front of
the file name so each time the file is rerun it won't write over the previous
file?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Date + Filename using save copy as


With Activeworkbook
.SaveAs Filename:= Format(Date,"yyyy mm dd") & " - " & .Name
End With

--

HTH

RP
(remove nothere from the email address if mailing direct)


"SKelley" wrote in message
...
I need to save a copy of a file each day the macro runs to a network
location. What is an easy way to code it to append the date to the front

of
the file name so each time the file is rerun it won't write over the

previous
file?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default Date + Filename using save copy as

This code is perfect so long as you only run it once a day... You probably
want to add in an On Error... something like...

On Error Goto LongFileName
With Activeworkbook
.SaveAs Filename:= Format(Date,"yyyy mm dd") & " - " & .Name
End With
on error goto 0

.... any more code you want here...

Exit Sub
LongFileName:
With Activeworkbook
.SaveAs Filename:= Format(Date,"yyyy mm dd") & " - " &
Format(Time,"hh:mm:ss") & " - " & .Name
End With
resume next
end sub

Or something like that. It appends the time to the date to make a unique
file name. This code is untested but it should work. If I know Bob he
probably has a better way but that is how I would do it...

HTH

"Bob Phillips" wrote:


With Activeworkbook
.SaveAs Filename:= Format(Date,"yyyy mm dd") & " - " & .Name
End With

--

HTH

RP
(remove nothere from the email address if mailing direct)


"SKelley" wrote in message
...
I need to save a copy of a file each day the macro runs to a network
location. What is an easy way to code it to append the date to the front

of
the file name so each time the file is rerun it won't write over the

previous
file?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Date + Filename using save copy as

Thanks for your help

"Jim Thomlinson" wrote:

This code is perfect so long as you only run it once a day... You probably
want to add in an On Error... something like...

On Error Goto LongFileName
With Activeworkbook
.SaveAs Filename:= Format(Date,"yyyy mm dd") & " - " & .Name
End With
on error goto 0

... any more code you want here...

Exit Sub
LongFileName:
With Activeworkbook
.SaveAs Filename:= Format(Date,"yyyy mm dd") & " - " &
Format(Time,"hh:mm:ss") & " - " & .Name
End With
resume next
end sub

Or something like that. It appends the time to the date to make a unique
file name. This code is untested but it should work. If I know Bob he
probably has a better way but that is how I would do it...

HTH

"Bob Phillips" wrote:


With Activeworkbook
.SaveAs Filename:= Format(Date,"yyyy mm dd") & " - " & .Name
End With

--

HTH

RP
(remove nothere from the email address if mailing direct)


"SKelley" wrote in message
...
I need to save a copy of a file each day the macro runs to a network
location. What is an easy way to code it to append the date to the front

of
the file name so each time the file is rerun it won't write over the

previous
file?




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Date + Filename using save copy as

I've got it to append the date to the filename now but I'm having trouble
with it saving the file on the network drives. Any idea on how to get it to
do both functions. Append date to filename and save in a new location. Thanks

"SKelley" wrote:

I need to save a copy of a file each day the macro runs to a network
location. What is an easy way to code it to append the date to the front of
the file name so each time the file is rerun it won't write over the previous
file?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cell("filename") doesn't update to new filename when do save as. Louis Excel Worksheet Functions 2 March 22nd 07 07:27 PM
set filename to <filename-date on open bob engler Excel Worksheet Functions 2 July 13th 06 05:11 AM
Auto save file copy with unique filename Allen Excel Worksheet Functions 1 June 27th 06 08:18 PM
Save date in filename Mike Excel Programming 6 February 24th 04 02:12 PM
Save Filename+Date+Time? Scooby912 Excel Programming 1 July 25th 03 06:21 PM


All times are GMT +1. The time now is 06:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"