![]() |
|
#5
|
|||
|
|||
|
The key language in the following macro is:
Code:
strName = strName & " " & ActiveDocument.ContentControls(1).Range.Text 'add name from first content control Here is a pair of macros that I use: Code:
Sub FileSaveAs()
' Run as substitute for FileSave to add date to default document names
' Charles Kenyon 2017, 2019, 2020
' Appends date to Title Document property 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
Dim strPath As String 'Holder for current path
Let strPath = Application.Options.DefaultFilePath(wdDocumentsPath)
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 = strPath & strName
.Show
End With
' Reset save path
Let Application.Options.DefaultFilePath(wdDocumentsPath) = strPath
' empty object
Set dlgSave = Nothing
End Sub
Sub FileSave()
FileSaveAs
End Sub
This grabs the Title from document properties and adds the content of the first content control in the document and then the date. |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Creating a template with repeat of fields and user input | jhansrod | Word VBA | 0 | 06-13-2019 08:03 AM |
| Linking Specific text fields in PP to specific cells in an Excel table | GWRW1964 | PowerPoint | 0 | 02-26-2018 07:37 AM |
How do I update all fields from a new input
|
Kozzzle | Word | 7 | 10-19-2017 06:12 PM |
| Help with Macro to Save Word File as PDF in Specific Location | ekimisme | Word VBA | 1 | 06-07-2017 10:40 PM |
| Save Excel file with specific cell value by using VBA code | IAMCHEESE | Excel Programming | 1 | 11-02-2016 07:11 PM |