
Originally Posted by
JDS_916
The revised FileSave() macro amends the title field based on any changes made to other fields on the document information panel (after the document has been saved once). However, it goes on to display the SaveAs dialog when all I want it to do is save the changes. The SaveAs is still required for creating the actual document.
As coded, the Save As is invoked if there's been a change to the components that constitute "Title". This, of course, applies when the file is created, but also when any of the input details are changed. It goes straight through to the save, though, if those details haven't changed. Isn't that what you wanted?
The message boxes display the errors when dates are entered incorrectly. However, when I click on okay in the message box, the FileSave() macro continues to run. I suppose it's tricky because this code runs as part of the FileSave() macro. I really need the user to enter the correct dates before the document is saved. Is it possible to exit or cancel out of the macro and keep forcing the user to enter a valid date range.
To handle that, you could change:
Sub FileSave()
Dim strfName
Call Document_ContentControlOnExit(ActiveDocument.SelectContentControlsByTitle("Visit Date - To")(1), False)
With ActiveDocument
to:
Sub FileSave()
Dim strfName
With ActiveDocument
Call Document_ContentControlOnExit(.SelectContentControlsByTitle("Visit Date - To")(1), False)
With .SelectContentControlsByTitle("Visit Date - To")(1)
If .Range.Text = .PlaceholderText Then Exit Sub
End With
With .SelectContentControlsByTitle("Visit Date - From")(1)
If .Range.Text = .PlaceholderText Then Exit Sub
End With