View Single Post
 
Old 12-07-2014, 03:46 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,521
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The problem was that you'd deleted the placeholder text for the two date controls. The following macro will fix that:
Code:
Sub FixDateCtrls()
With ActiveDocument.SelectContentControlsByTitle("Select Date")
  .Item(1).SetPlaceholderText Text:="Select Date"
  .Item(2).SetPlaceholderText Text:="Select Date"
End With
End Sub
With the ContentControlOnExit macro itself, it seems you haven't really understood how it works. You really don't need to include all of "Dropdown1", "Date1", "Text1", "Select", "Select Date" for the Title selection when you're only concerned with "Select" & "Select Date". Furthermore, when testing the content control's display, you don't need to test all of .PlaceholderText, "n/a", "Choose an Item", "If Yes, Select", "Select Date", when "Choose an Item" & "Select Date" (after running the above macro) are themselves the Placeholder text.

Try the following:
Code:
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean)
Application.ScreenUpdating = False
With CCtrl
  Select Case .Title
    Case "Select"
      Select Case .Range.Text
        Case .PlaceholderText, "n/a", "If Yes, Select"
          .Range.Font.ColorIndex = wdRed
        Case Else
        .Range.Font.ColorIndex = wdAuto
      End Select
    Case "Select Date"
      Select Case .Range.Text
        Case .PlaceholderText
          .Range.Font.ColorIndex = wdRed
        Case Else
        .Range.Font.ColorIndex = wdAuto
      End Select
      With .Range.Font
        .Size = 8
        .Italic = True
      End With
    Case Else
  End Select
End With
Application.ScreenUpdating = True
End Sub
Note how I have separate processes for the 'Select' & 'Select Date' controls. That basically comes down to the latter using italics and to coerce it to remain at 8pt when displaying the Placeholder text - which wouldn't be necessary if you used a Style with those attributes.

You might also want to set each content control's 'cannot be deleted' property, to guard against errant users.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote