Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Save File with Date and Time Stamp

Hi All,

How do I save a file with a date and time stamp?

I need the filename to include BOTH the date and the time?

Thanks

Andi


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Save File with Date and Time Stamp

Activeworkbook.SaveAs Filename:= Format(now,"yyyy-mm-dd hh:mm" )

--

HTH

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


"Andibevan" wrote in message
...
Hi All,

How do I save a file with a date and time stamp?

I need the filename to include BOTH the date and the time?

Thanks

Andi




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default Save File with Date and Time Stamp

Andi, something like this,

Sub Save_As()
ActiveWorkbook.SaveAs Filename:="Test " & Format(Now,
"mm-dd-yyyy-hh-mm") & ".xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False _
, CreateBackup:=False
End Sub


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"Andibevan" wrote in message
...
Hi All,

How do I save a file with a date and time stamp?

I need the filename to include BOTH the date and the time?

Thanks

Andi




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Save File with Date and Time Stamp

Hi Andibevan

Try this

Sub test()
Dim strdate As String
strdate = Format(Now, "dd-mm-yy h-mm-ss")
With ActiveWorkbook
.SaveAs "C:\" & strdate & ".xls"
End With
End Sub




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


"Andibevan" wrote in message ...
Hi All,

How do I save a file with a date and time stamp?

I need the filename to include BOTH the date and the time?

Thanks

Andi



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Save File with Date and Time Stamp

Cheers All

"Ron de Bruin" wrote in message
...
Hi Andibevan

Try this

Sub test()
Dim strdate As String
strdate = Format(Now, "dd-mm-yy h-mm-ss")
With ActiveWorkbook
.SaveAs "C:\" & strdate & ".xls"
End With
End Sub




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


"Andibevan" wrote in message
...
Hi All,

How do I save a file with a date and time stamp?

I need the filename to include BOTH the date and the time?

Thanks

Andi







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Save File with Date and Time Stamp


Is it possible to include a ":" between "the hour" and "the minute" in
time stamp used as part of a filename (file to be saved by VBA code)?
Normally, VBA will not allow this.

Thanks for a response,
Chuckles12

--
Chuckles12
-----------------------------------------------------------------------
Chuckles123's Profile: http://www.excelforum.com/member.php...fo&userid=1494
View this thread: http://www.excelforum.com/showthread.php?threadid=38038

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Save File with Date and Time Stamp

Windows won't allow colons in the file name.

I use the underscore (_) as a separator if I really want one.

Chuckles123 wrote:

Is it possible to include a ":" between "the hour" and "the minute" in a
time stamp used as part of a filename (file to be saved by VBA code)?
Normally, VBA will not allow this.

Thanks for a response,
Chuckles123

--
Chuckles123
------------------------------------------------------------------------
Chuckles123's Profile: http://www.excelforum.com/member.php...o&userid=14948
View this thread: http://www.excelforum.com/showthread...hreadid=380389


--

Dave Peterson
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Save File with Date and Time Stamp

How would I properly insert the underscore (_). When it saves it saves like
20060503-2006_05_03-162230.xls
this is how I have it written, how can I change it to save like
2006_05_03-162230.xls

With ActiveWorkbook
.SaveAs Left(ActiveWorkbook.FullName, _
InStr(1, ActiveWorkbook.FullName, "-")) _
& Format(Now, "yyyy(_)mm(_)dd-hhmmss") & ".xls"
End With

"Dave Peterson" wrote:

Windows won't allow colons in the file name.

I use the underscore (_) as a separator if I really want one.

Chuckles123 wrote:

Is it possible to include a ":" between "the hour" and "the minute" in a
time stamp used as part of a filename (file to be saved by VBA code)?
Normally, VBA will not allow this.

Thanks for a response,
Chuckles123

--
Chuckles123
------------------------------------------------------------------------
Chuckles123's Profile: http://www.excelforum.com/member.php...o&userid=14948
View this thread: http://www.excelforum.com/showthread...hreadid=380389


--

Dave Peterson

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Save File with Date and Time Stamp

Dim mySuffix as string
mysuffix = format(now,"yyyy_mm_dd-hhmmss") & ".xls"

I think???

Curt D. wrote:

How would I properly insert the underscore (_). When it saves it saves like
20060503-2006_05_03-162230.xls
this is how I have it written, how can I change it to save like
2006_05_03-162230.xls

With ActiveWorkbook
.SaveAs Left(ActiveWorkbook.FullName, _
InStr(1, ActiveWorkbook.FullName, "-")) _
& Format(Now, "yyyy(_)mm(_)dd-hhmmss") & ".xls"
End With

"Dave Peterson" wrote:

Windows won't allow colons in the file name.

I use the underscore (_) as a separator if I really want one.

Chuckles123 wrote:

Is it possible to include a ":" between "the hour" and "the minute" in a
time stamp used as part of a filename (file to be saved by VBA code)?
Normally, VBA will not allow this.

Thanks for a response,
Chuckles123

--
Chuckles123
------------------------------------------------------------------------
Chuckles123's Profile: http://www.excelforum.com/member.php...o&userid=14948
View this thread: http://www.excelforum.com/showthread...hreadid=380389


--

Dave Peterson


--

Dave Peterson
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) 3 October 7th 08 06:14 PM
product date stamp file save Robert Loxley Excel Discussion (Misc queries) 12 November 13th 06 02:48 PM
How can you save a spreadsheet with a date stamp. kenny Excel Worksheet Functions 1 May 15th 06 05:19 PM
Save as w/ Time Stamp Arturo Excel Programming 2 February 22nd 05 12:49 AM
Getting a File Date & Time stamp James Excel Programming 5 February 8th 05 07:15 PM


All times are GMT +1. The time now is 02:52 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"