Solved

Saving a file that increments the date in specific format.

Posted on 2013-12-27
5
225 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

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

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

Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

624 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