+ Reply to Thread
Results 1 to 12 of 12

Save File with Date and Time Stamp

  1. #1
    Andibevan
    Guest

    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. #2
    Paul B
    Guest

    Re: 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" <[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
    >
    >




  3. #3
    Bob Phillips
    Guest

    Re: 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" <[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
    >
    >




  4. #4
    Ron de Bruin
    Guest

    Re: 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" <[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
    >




  5. #5
    Andibevan
    Guest

    Re: Save File with Date and Time Stamp

    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
    >>

    >
    >




  6. #6
    Forum Contributor
    Join Date
    10-03-2004
    Posts
    102

    Special Character (:) In Filename???

    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

  7. #7
    Ardus Petus
    Guest

    Re: Save File with Date and Time Stamp

    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
    >




  8. #8
    Dave Peterson
    Guest

    Re: 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. #9
    Curt D.
    Guest

    Re: 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. #10
    Dave Peterson
    Guest

    Re: 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

  11. #11
    Registered User
    Join Date
    12-25-2019
    Location
    India
    MS-Off Ver
    2016
    Posts
    1

    How to get date automatically from the file name

    Hello,

    I need VBA Macros from the file name which contains date.
    For that date it should be directly added in one new column for the date which is in file name.

  12. #12
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,051

    Re: How to get date automatically from the file name

    Quote Originally Posted by Lavanyah View Post
    Hello,

    I need VBA Macros from the file name which contains date.
    For that date it should be directly added in one new column for the date which is in file name.
    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1