Solved

Saving a file that increments the date in specific format.

Posted on 2013-12-27
5
223 Views
Last Modified: 2014-01-02
How can this be changed to increment the date into the filename?
Desired filename and format: Bruce Shortage Report ddmmyy.xlsx
can mm be abbreviated month like Dec, Nov, ?
I get sick of having to go out to the W drive and adding it everyday..  thanks -R-

Sub SaveFileToWDrive()
'
    ChDir "W:\Holland\rrw5"
    ActiveWorkbook.SaveAs Filename:= _
        "W:\Holland\rrw5\Bruce Shortage Report.xlsx", FileFormat:= _
        xlOpenXMLWorkbook, CreateBackup:=False
    ActiveWorkbook.Close
    MsgBox ("File Saved to W:\Holland\rrw5\ [        ]")
    
End Sub

Open in new window

0
Comment
Question by:RWayneH
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 40

Accepted Solution

by:
als315 earned 500 total points
ID: 39742284
Sub SaveFileToWDrive()
Dim FName As String
'
 FName = "W:\Holland\rrw5\Bruce Shortage Report "
 FName = FName & Format(Date, "ddmmmyy") & ".xlsx"
    'ChDir "W:\Holland\rrw5"
    ActiveWorkbook.SaveAs Filename:= _
        FName, FileFormat:= _
        xlOpenXMLWorkbook, CreateBackup:=False
    ActiveWorkbook.Close
    MsgBox ("File Saved to " & FName)
    
End Sub

Open in new window

0
 

Author Comment

by:RWayneH
ID: 39742335
Thanks, one more quick question on the date format, if they wanted to put a - or dot in the date would this work?

FName = FName & Format(Date, "dd'."mmm'."yy") & ".xlsx"  I know someone is going to ask to chg that around.  Thanks. -R-
0
 
LVL 40

Expert Comment

by:als315
ID: 39742376
No, you can use non reserved symbols inside string:
Format(Date, "dd-mmm-yy")
http://msdn.microsoft.com/en-us/library/office/gg251755.aspx
0
 
LVL 20

Expert Comment

by:clarkscott
ID: 39743337
If you really wanted this sorted better, I'd use "yyyy-mm-dd".

Scott C
0
 

Author Closing Comment

by:RWayneH
ID: 39752937
Thanks. -R-
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question