Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-12-2017, 04:57 PM
JonniBravo JonniBravo is offline Save document multiple times with date as filename Windows 7 64bit Save document multiple times with date as filename Office 2016
Novice
Save document multiple times with date as filename
 
Join Date: Mar 2017
Posts: 2
JonniBravo is on a distinguished road
Default Save document multiple times with date as filename

Hi All,

I have a document that I use for work which is filled in every day with details of the shift to pass on to the shift coming on. These files are saved


01 01 2017 day
01 01 2017 Night
02 01 2017 day
02 01 2017 Night and so on, and filed for future reference so they are always saved with the date as the filename.

I also have two date fields in the file itself that I want to change with the filename.

So what I am asking is! Is there a way to save the file multiple times with the dates changing in the text fields and the file name, is this possible.
Reply With Quote
  #2  
Old 03-12-2017, 09:31 PM
gmayor's Avatar
gmayor gmayor is offline Save document multiple times with date as filename Windows 10 Save document multiple times with date as filename Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

This is easily achieved with a macro, but how and when do you intend to save the documents. e.g. Today do you want to save the two documents with tomorrow's date or the two documents with today's date orthe two documents with a raft of dates - in which case which?
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 03-12-2017, 10:04 PM
JonniBravo JonniBravo is offline Save document multiple times with date as filename Windows 7 64bit Save document multiple times with date as filename Office 2016
Novice
Save document multiple times with date as filename
 
Join Date: Mar 2017
Posts: 2
JonniBravo is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
This is easily achieved with a macro, but how and when do you intend to save the documents. e.g. Today do you want to save the two documents with tomorrow's date or the two documents with today's date orthe two documents with a raft of dates - in which case which?

I want to save the same document for every day of each month, all in one day. Its basically a diary of the days work so I would want one for every day of the year that I will organise into separate folders one for each month. So if its the 4th July they can goto the document dated 04 07 2017 and make the entry for the day.

The problem is people keep opening the previous days document make the entry for the day and they don't change the filename date and save over a previous document so I want to create a years worth of documents so staff can just open the one that is dated for that day and they don't have to think about saving the file with the correct date.

Sorry I hope I am making sense.

If possible I would also like the macro to change the date inside the document itself.
Reply With Quote
  #4  
Old 03-13-2017, 01:40 AM
macropod's Avatar
macropod macropod is offline Save document multiple times with date as filename Windows 7 64bit Save document multiple times with date as filename Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by JonniBravo View Post
The problem is people keep opening the previous days document make the entry for the day and they don't change the filename date and save over a previous document
The real problem is that you and/or your users are editing existing documents instead of creating new ones from a template. If you used a template, there would be little risk of an existing document being overwritten.

See:
https://support.office.com/en-us/art...2-1191BCE57DEB
https://support.office.com/en-us/art...2-57A2168C1E89
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 03-13-2017, 07:14 AM
Charles Kenyon Charles Kenyon is offline Save document multiple times with date as filename Windows 10 Save document multiple times with date as filename Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,140
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

When you create your template, you can put in CREATEDATE fields for both date and time if you want. Using Date Fields in Microsoft Word
Unlike the DATE field, these will remain fixed.

I agree, strongly, with Paul that you want to be using a template.
You can use a macro in the template to attach the date and time to the filename.
Reply With Quote
  #6  
Old 03-13-2017, 11:19 AM
Charles Kenyon Charles Kenyon is offline Save document multiple times with date as filename Windows 10 Save document multiple times with date as filename Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,140
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

The following pair of macros work to append a date to whatever is in the Title document property in the template for a new document.

Code:
Public Sub SaveWithDate(Optional strName As String)
    ' Run as substitute for FileSave to add date to default document names
    ' Put in a document or global template as public macro
    ' This is called from other macros which may supply a name strName
    ' If strName is supplied, it is used as the base name, otherwise the base comes from the Title Property
     '
    Dim dlgSave As Dialog
    On Error Resume Next
    '   
    If Len(ActiveDocument.Path) > 0 Then
      ' The document has already been saved at least once.
      ' Just save and exit the macro.
      ActiveDocument.Save
      Exit Sub
    End If
    '
    If strName = "" Then strName = strName & ActiveDocument.BuiltInDocumentProperties("Title").Value        'get name in title
    ActiveDocument.BuiltInDocumentProperties("Title").Value = strName
    '    
    strName = strName & " " & Format((Year(Now() + 1) Mod 100), "20##") & "-" & _
        Format((Month(Now() + 1) Mod 100), "0#") & "-" & _
        Format((Day(Now()) Mod 100), "0#")
    '
    Set dlgSave = Dialogs(wdDialogFileSaveAs)
    With dlgSave
        .Name = strName
        .Show
        
    End With
End Sub

Sub FileSave()
    Application.Run "SaveWithDate"
End Sub
That code should be in your template. It intercepts the FileSave command and proposes a name. If the file already has a name, it simply saves.

Your users, I would hope, could add the DAY or NIGHT to the name.

Note, this does not intercept the SaveAs command. It will activate is someone tries to close a new document without saving and then responds to the query that they do want to save it.

I wrote this with substantial help from others on one of these forums. The date will be in the format YYYY-MM-DD. When appended to a standard name, the files sort nicely in alphabetical order. You could change the order to what you are using now, I suppose.

See Installing Macros for information about how to use this code if you don't know.
Reply With Quote
  #7  
Old 03-13-2017, 11:35 AM
Charles Kenyon Charles Kenyon is offline Save document multiple times with date as filename Windows 10 Save document multiple times with date as filename Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,140
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

That macro was designed to be called from another macro that would supply a name. You could simplify the process:

Code:
Public Sub FileSave()
    ' Run as substitute for FileSave to add date to default document names
    ' Put in a document or global template as public macro
    ' Base name comes from the Title Property in the template

    Dim dlgSave As Dialog
        On Error Resume Next
   
    If Len(ActiveDocument.Path) > 0 Then
      ' The document has already been saved at least once.
      ' Just save and exit the macro.
      ActiveDocument.Save
      Exit Sub
    End If
    '
     'get name from title property
    strName = ActiveDocument.BuiltInDocumentProperties("Title").Value
    '   
    strName = strName & " " & Format((Year(Now() + 1) Mod 100), "20##") & "-" & _
        Format((Month(Now() + 1) Mod 100), "0#") & "-" & _
        Format((Day(Now()) Mod 100), "0#")
'
    Set dlgSave = Dialogs(wdDialogFileSaveAs)
    With dlgSave
        .Name = strName
        .Show
    End With
End Sub
Remember, if you want any base name rather than just the date, put that name in the Title property of your template.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Save document multiple times with date as filename How can I save a Word Document as a PDF file with a merged field filename? kp2009 Word VBA 5 08-27-2015 11:45 PM
Using DocProperty Field Codes multiple times in the same document trueimage Word 2 09-18-2013 04:44 PM
Save document multiple times with date as filename Appending the filename with the current date sheeand Word VBA 2 05-14-2012 05:18 AM
Save document multiple times with date as filename How to insert current date into default filename ? czomberzdaniela Word 1 12-27-2011 07:18 PM
Save document multiple times with date as filename Save Filename using Document Text Knawl Word 11 10-10-2011 03:00 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:45 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft