Version of Word?
I do this by having the information in Content Controls and having the Save and Save As commands intercepted to get that information.
That is the simplest way I have to identify information by location.
Here is the code I am using which picks up information in the first Content Control. Perhaps it will help.
Code:
Sub FileSave()
' Run as substitute for FileSave to add date to default document names
' Charles Kenyon 2017
' Appends date to Content Control Results when saving
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
'
'
Dim strName As String, dlgSave As Dialog
Set dlgSave = Dialogs(wdDialogFileSaveAs)
strName = ActiveDocument.BuiltInDocumentProperties("Title").Value 'get name in title
'
strName = strName & " " & ActiveDocument.ContentControls(1).Range.Text 'add name from first content control
strName = strName & " " & Format((Year(Now() + 1) Mod 100), "20##") & "-" & _
Format((Month(Now() + 1) Mod 100), "0#") & "-" & _
Format((Day(Now()) Mod 100), "0#") 'add date
'
With dlgSave
.Name = strName
.Show
End With
End Sub
Sub FileSaveAs()
' Use above
FileSave
End Sub
This is for use in a
template for the document. If the document already has a name, it simply saves it. If not it assigns the name. The template has a base name in the Title document property. It also appends the current date in the format YYYY-MM-DD.
Install/Employ VBA Procedures (Macros)
Installing Macros