PC Review


Reply
Thread Tools Rate Thread

How date stamp & save filename?

 
 
=?Utf-8?B?amt0?=
Guest
Posts: n/a
 
      7th May 2007
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 With Quote
 
 
 
 
=?Utf-8?B?VmVyZ2VsIEFkcmlhbm8=?=
Guest
Posts: n/a
 
      8th May 2007
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

 
Reply With Quote
 
=?Utf-8?B?SGFsaW0=?=
Guest
Posts: n/a
 
      8th May 2007
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
timed save of documents with automated time stamp in filename ? (w2007) at453 Microsoft Word Document Management 2 9th Oct 2009 05:35 AM
Code issue - before_save() - Filename with date stamp - worksheet =?Utf-8?B?YXdyZXg=?= Microsoft Excel Programming 9 29th May 2007 10:16 PM
Automatically date stamp filename when save? =?Utf-8?B?U3luYy1vcHk=?= Microsoft Word Document Management 7 28th Mar 2007 07:13 AM
How can you save a spreadsheet with a date stamp. =?Utf-8?B?a2Vubnk=?= Microsoft Excel Worksheet Functions 1 15th May 2006 05:19 PM
Date Stamp Save oberon.black Microsoft Excel Programming 2 10th Sep 2005 06:17 PM


Features
 

Advertising
 

Newsgroups
 


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