![]() |
#1
|
|||
|
|||
![]()
I want to set the content of one cell of a table to be the default suggested filename when you save a document. I already investigated and found that Word's first choice for this default file name is the Document title property, so I tried this -- but the problem is that the last number in the text of this cell (2000 in this case) is a Document Property box itself, for the purpose of repeating that number in other parts of the document. I can't put a Document Property box within the Title document property box, so does anyone have any other ideas?
See attachment for clarification |
#2
|
|||
|
|||
![]()
Here is some code that may help. I haven't tested it.
Code:
Sub FileSave() ' Run as substitute for FileSave to add date to default document names ' Charles Kenyon 2017 ' 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 Set dlgSave = Dialogs(wdDialogFileSaveAs) strName = ActiveDocument.BuiltInDocumentProperties("Title").Value 'get name in title strName = strName & " " & ActiveDocument.ContentControls(2).Range.Text 'add name from second content control ' Append current date 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 This also appends a date. That was in the code I'm using so I threw it in. You could comment it out or delete it. Note this adds a space between the title and the control. If your second part is a re-purposed document property content control, you could identify it as we did for the Title property. |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Title versus Titre in file properties... | Gael | Word | 4 | 08-28-2015 07:59 AM |
![]() |
rslck | Outlook | 1 | 06-19-2014 10:16 AM |
![]() |
thedr9wningman | Word VBA | 3 | 01-20-2014 05:56 PM |
![]() |
czomberzdaniela | Word | 1 | 12-27-2011 07:18 PM |
![]() |
czomberzdaniela | Word Tables | 8 | 04-12-2011 05:48 AM |