For the first issue, try:
Sub FileSave()
Dim strfName
Call Document_ContentControlOnExit(ActiveDocument.SelectContentControlsByTitle("Visit Date - To")(1), False)
With ActiveDocument
strfName = .ContentTypeProperties("RO").Value & Chr(32) & _
.CustomDocumentProperties("OfficeType").Value & Chr(32) & _
.ContentTypeProperties("Country(s)").Value & Chr(32) & _
.ContentControls(1).Range.Text & Chr(32) & _
.CustomDocumentProperties("ReportType").Value
If .BuiltInDocumentProperties("Title").Value <> strfName Then
.BuiltInDocumentProperties("Title").Value = strfName
With Dialogs(wdDialogFileSaveAs)
.Name = strfName & ".docx"
.Show
End With
Else
.Save
End If
End With
End Sub
For the second issue, try:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Application.ScreenUpdating = False
Dim Str1 As String, Str2 As String
With ContentControl
If (.Title = "Visit Date - From") Or (.Title = "Visit Date - To") Then
If .Range.Text = .PlaceholderText Then Exit Sub
If .Title = "Visit Date - From" Then
.Range.ParentContentControl.DateDisplayFormat = "D MMMM YYYY"
Str1 = .Range.Text
With ActiveDocument.SelectContentControlsByTitle("Visit Date - To")(1)
.Range.ParentContentControl.DateDisplayFormat = "D MMMM YYYY"
Str2 = .Range.Text
End With
Else
With ActiveDocument.SelectContentControlsByTitle("Visit Date - From")(1)
.Range.ParentContentControl.DateDisplayFormat = "D MMMM YYYY"
Str1 = .Range.Text
End With
Str2 = .Range.Text
End If
If Format(Str1, "YYYYMMDD") > Format(Str2, "YYYYMMDD") Then
ActiveDocument.SelectContentControlsByTitle("Visit Date - To")(1).Range.Text = ""
ActiveDocument.SelectContentControlsByTitle("Visit Date - From")(1).Range.Text = ""
MsgBox "'Visit Date - From' is greater than 'Visit Date - To'" & _
vbCr & vbTab & "Please re-input the correct dates", vbCritical
ElseIf Format(Str1, "YYYYMMDD") = Format(Str2, "YYYYMMDD") Then
ActiveDocument.SelectContentControlsByTitle("Visit Date - To")(1).Range.Text = ""
ActiveDocument.SelectContentControlsByTitle("Visit Date - From")(1).Range.Text = ""
MsgBox "'Visit Date - From' is the same as 'Visit Date - To'" & _
vbCr & vbTab & "Please re-input the correct dates", vbCritical
Else
With ActiveDocument.SelectContentControlsByTitle("Visit Date - From")(1)
If Split(Str1, " ")(2) = Split(Str2, " ")(2) Then
If Split(Str1, " ")(1) = Split(Str2, " ")(1) Then
.Range.ParentContentControl.DateDisplayFormat = "D' to '"
Else
.Range.ParentContentControl.DateDisplayFormat = "D MMMM' to '"
End If
End If
End With
End If
End If
End With
Application.ScreenUpdating = True
End Sub