Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
jkt jkt is offline
external usenet poster
 
Posts: 3
Default How date stamp & save filename?

I want to save a file as its original filename with today's date applied to
the end of the filename.

For example:

filename = budget.xls

I open, make changes, etc., click macro button. File is saved as
budget_5-7-2007.xls

Can someone help me do this? I wan the same directory location as the
original file to be used when saving.

thanks,
jkt
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default How date stamp & save filename?

Maybe something like this would work for you... But note that if your
original file name would have an underscore character, you might run into
problems..

Sub jkt()
Dim iPos As Integer

With ThisWorkbook
iPos = InStrRev(.Name, "_")
If iPos = 0 Then
.SaveAs .Path & "\" & Replace(.Name, ".XLS", "_" & Format(Now,
"m-d-yyyy") & ".xls", 1, -1, vbTextCompare)
Else
.SaveAs .Path & "\" & Left(.Name, iPos) & Format(Now, "m-d-yyyy") &
".xls"
End If
End With

End Sub



--
Hope that helps.

Vergel Adriano


"jkt" wrote:

I want to save a file as its original filename with today's date applied to
the end of the filename.

For example:

filename = budget.xls

I open, make changes, etc., click macro button. File is saved as
budget_5-7-2007.xls

Can someone help me do this? I wan the same directory location as the
original file to be used when saving.

thanks,
jkt

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 182
Default How date stamp & save filename?

Hi jkt,

You might have duplication file unless you delete it after you saveas...
you can try this one:

Sub SaveAsDate()
Dim Wbk As Workbook, Addr As String
Set Wbk = Workbooks("ABC.xls")
Addr = Wbk.FullName 'need variable to delete file
Wbk.SaveAs Replace(.Name, ".xls", "") & "_" & _
Format$(Now, "m-d-yyyy") & ".xls"
Kill Addr
End Sub

--

Regards,

Halim


"jkt" wrote:

I want to save a file as its original filename with today's date applied to
the end of the filename.

For example:

filename = budget.xls

I open, make changes, etc., click macro button. File is saved as
budget_5-7-2007.xls

Can someone help me do this? I wan the same directory location as the
original file to be used when saving.

thanks,
jkt

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
Excel 2007 Changes date stamp on Save As Williams Excel Discussion (Misc queries) 4 November 6th 08 06:24 PM
How can you save a spreadsheet with a date stamp. kenny Excel Worksheet Functions 1 May 15th 06 05:19 PM
Save File with Date and Time Stamp Andibevan[_3_] Excel Programming 9 May 4th 06 01:17 AM
Save file with time date stamp oberon.black[_91_] Excel Programming 1 September 22nd 05 01:13 AM
Date Stamp Save oberon.black[_29_] Excel Programming 2 September 10th 05 06:17 PM


All times are GMT +1. The time now is 12:41 AM.

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

About Us

"It's about Microsoft Excel"