As a technical copywriter who uses Word on a daily basis, I have often found myself wishing I’d saved more iterations of my document. Especially when working on longer or more complex documents.
One method that I used to use was to append a, b, c, to the filename and then this would stack up in the folder.
However, when you get in the flow, even pressing Alt, F, A (to access ‘Save As’), Y3 (to select the file name field) pressing the right arrow key (to go to the end of the filename), and then type in the letter was either way too many keystrokes for me (or it was a mouse/keyboard combi, which was probably why it didn’t sit well).
It was just a little too slow and I’d often forget to save as, meaning the potential to lose work on a roll-back was riskier than ever.
Sure, you could rely on Word’s autosave but, personally, I’d rather not.
Word ‘Save As’ using VBA
This is why I came up with the idea to append both the date, as I already did (in yymmdd format), plus add the time to it, also: yymmdd_hhmm.
Now, it stacks up even better, only needs either a shortcut key combination to run the macro, or at most 2 clicks of the mouse.
Now, the files stack up like:
So much easier. So much quicker. And with little to no disruption to my workflow.
If you want to try this out on your own machine, the following 6 videos show the entire process of how to do it.
If you have any questions for me, fire away and I’ll try and get to them as soon as I’m able.
01 – Introduction
Here we take a look at how this process works. That way you can see how easy, effective, and useful it is.
We will look at, and walkthrough, the code in the next video.
Templates File Path
The filepath to your templates folder is:
C:\Users\{username}\AppData\Roaming\Microsoft\Templates
Where {username} is your logged in username, i.e. if I was logged in as Russ, the file path would be:
C:\Users\Russ\AppData\Roaming\Microsoft\Templates
Get the VBA Code and Your Templates File Path
Note: Such are the times we live in that I have to say ‘use this code at your own risk’.
I do use it myself (and it works perfectly for me). However, I have zero control over how you use it and if something goes wrong, then that’s down to you.
You can see the code in use in the videos, you can see what it does. If that works for you and you can use it, go for it; if it doesn’t, or you don’t want to do it, that’s fine — it’s your choice. But I have zero liability here and by downloading/using the code, you acknowledge that. If you don’t, don’t use it.
Click here to download the text file containing the ‘Save as’ code.
Sub save_new_filename()
'Declare variables
Dim mystr As String 'this gets the current date and time
Dim filepath As String 'this gets the file path property value for the filename
Dim filetitle As String 'this gets the title name for the filename
Dim fullstring As String 'this variable is used to collate file path, title, and date and used for the 'save as'
Dim Response As Integer 'we need this for the msgbox response
Dim xdlg As Dialog 'this is for when we need to show the save as dialog
'===================================================================
'================= Save the file? ===================
'===================================================================
'If the file hasn't been saved and there's no title property, then prompt for it.
'If the user declines, then the save as dialog shows.
If (ActiveDocument.path = "") And ActiveDocument.BuiltInDocumentProperties(wdPropertyTitle).Value = "" Then
Response = MsgBox("We need a title... Click Yes to open the dialog or No to abort.", vbYesNo + vbQuestion, "Exit?")
Select Case Response
Case vbYes
Call show_docinformation_panel
Case vbNo
Set xdlg = Dialogs(wdDialogFileSaveAs)
xdlg.Show
End Select
ElseIf (ActiveDocument.path = "") And ActiveDocument.BuiltInDocumentProperties(wdPropertyTitle).Value <> "" Then
Set xdlg = Dialogs(wdDialogFileSaveAs)
xdlg.Show
End If
'========================================================================
'================= If no title exists, prompt for one ===================
'========================================================================
'If there is no title property, then the message box will open and notify.
'There are 2 responses: Yes, opens the doc info panel; no, closes the messagebox and ends this subroutine, i.e. returns to the document with no changes made
If ActiveDocument.BuiltInDocumentProperties(wdPropertyTitle).Value = "" Then
Response = MsgBox("We need a title... Click Yes to open the dialog or No to abort.", vbYesNo + vbQuestion, "Exit?")
Select Case Response
Case vbYes
Call show_docinformation_panel
Case vbNo
Exit Sub
End Select
End If
'There might be a case where the user clicked Yes to add a title, and then cancelled before adding it
'In this case, this clause prevents the file from saving without a title
If ActiveDocument.BuiltInDocumentProperties(wdPropertyTitle).Value = "" Then
MsgBox "No title entered."
Exit Sub
End If
'========================================================================
'========= Now we collate the above into a new filename and save ========
'========================================================================
'Here we assign the properties to easier to remember items. We don't have to do this, as there's enough info above,
'but it makes it much easier to follow what's happening
filepath = ActiveDocument.path & "\"
filetitle = ActiveDocument.BuiltInDocumentProperties(wdPropertyTitle).Value
mystr = Format(Now, "yymmdd_hhmm")
'Now we've defined the 3 properties or components required, we bring them all together
fullstring = filepath & filetitle & "_" & mystr & ".docx"
'The following line saves the new filename in the correct format for a docx file
ActiveDocument.SaveAs FileName:=fullstring, FileFormat:=wdFormatXMLDocument
End Sub
Sub show_docinformation_panel()
On Error Resume Next
If Application.DisplayDocumentInformationPanel = True Then
Application.DisplayDocumentInformationPanel = False
ElseIf Application.DisplayDocumentInformationPanel = False Then
Application.DisplayDocumentInformationPanel = True
End If
End Sub
Note: as far as I am aware, all the above code is my own/gleaned and modified for my own use from public online sources. If you believe I’ve copied someone else’s and not credited them, then let me know and I’ll be happy to change that.