Solved

Saving a file that increments the date in specific format.

Posted on 2013-12-27
5
219 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
  • 2
  • 2
5 Comments
 
LVL 39

Accepted Solution

by:
als315 earned 500 total points
Comment Utility
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
Comment Utility
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 39

Expert Comment

by:als315
Comment Utility
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
Comment Utility
If you really wanted this sorted better, I'd use "yyyy-mm-dd".

Scott C
0
 

Author Closing Comment

by:RWayneH
Comment Utility
Thanks. -R-
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now