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
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
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" <[email protected]> wrote in message
news:[email protected]...
> 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
>
>
Activeworkbook.SaveAs Filename:= Format(now,"yyyy-mm-dd hh:mm" )
--
HTH
RP
(remove nothere from the email address if mailing direct)
"Andibevan" <[email protected]> wrote in message
news:[email protected]...
> 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
>
>
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" <[email protected]> wrote in message news:[email protected]...
> 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
>
Cheers All
"Ron de Bruin" <[email protected]> wrote in message
news:[email protected]...
> 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" <[email protected]> wrote in message
> news:[email protected]...
>> 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
>>
>
>
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
AFAIK, the ":" in filename is not allowed by Windows, not by VBA
HTH
--
AP
"Chuckles123" <[email protected]> a
écrit dans le message de news:
[email protected]...
>
> 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
>
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
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
>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks