+ Reply to Thread
Results 1 to 4 of 4

Include current date in filepath

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-12-2014
    Location
    Boston, MA
    MS-Off Ver
    Office 2010
    Posts
    172

    Include current date in filepath

    Here is my current code:

    Workbooks.Add
        ChDir "H:\Desktop\Pipeline\Blank Manager Pipelines"
        ActiveWorkbook.SaveAs Filename:= _
            "H:\Desktop\Pipeline\Blank Manager Pipelines\BASSANI_ & Left(Now(), 10).xlsx", _
            FileFormat:=xlOpenXMLWorkbook
    The workbook is saving as Bassani_ & Left(Now(), 10).xlsx rather than Bassani_04142015 which is what I need it to do. I'm trying different ways but I can't seem to get the naming right. Everything else works fine

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Include current date in filepath

    Try this

    msgbox Format(Now(), "mmddyyyy")
         ChDir "H:\Desktop\Pipeline\Blank Manager Pipelines"
        ActiveWorkbook.SaveAs Filename:= _
            "H:\Desktop\Pipeline\Blank Manager Pipelines\BASSANI_" & Format(Now(), "mmddyyyy") & ".xlsx", _
            FileFormat:=xlOpenXMLWorkbook
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Valued Forum Contributor
    Join Date
    03-23-2008
    Location
    Tennessee
    MS-Off Ver
    Office 2007
    Posts
    706

    Re: Include current date in filepath

    Try below:

    ChDir "H:\Desktop\Pipeline\Blank Manager Pipelines"
        ActiveWorkbook.SaveAs Filename:= _
            "H:\Desktop\Pipeline\Blank Manager Pipelines\BASSANI_ & Left & " (" & Format(Date, "yyyymmdd") & ").xlsx" _
            , FileFormat:=xlOpenXMLWorkbook

  4. #4
    Valued Forum Contributor
    Join Date
    03-23-2008
    Location
    Tennessee
    MS-Off Ver
    Office 2007
    Posts
    706

    Re: Include current date in filepath

    Oops. Revised below:

    ChDir "H:\Desktop\Pipeline\Blank Manager Pipelines"
        ActiveWorkbook.SaveAs Filename:= _
            "H:\Desktop\Pipeline\Blank Manager Pipelines\BASSANI_ & " (" & Format(Date, "mmddyyyy") & ").xlsx" _
            , FileFormat:=xlOpenXMLWorkbook

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. setting filepath to current drive- not fully qualified
    By alexcrofut in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-23-2015, 07:16 PM
  2. Generating order numbers that include current date
    By werdnaegni in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 03-05-2013, 05:37 PM
  3. Replies: 4
    Last Post: 07-19-2010, 09:05 AM
  4. get current filepath in excel vba
    By matt in forum Excel General
    Replies: 4
    Last Post: 03-14-2006, 11:50 AM
  5. Replies: 3
    Last Post: 03-09-2006, 02:10 PM

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