Handy Feature with ContentControl Titles

G

Greg Maxey

I was thumping around with ContentControls today and discovered a feature
that might be handy. You can set/alter the title using VBA and the
OnEntry/OnExit events. While the string length is limited to 64 characters
it has possibilities. I created a CC tagged "LifeStory" and ran this code:

Private Sub Document_ContentControlOnEnter(ByVal CC As ContentControl)
Select Case CC.Tag
Case Is = "LifeStory"
If CC.ShowingPlaceholderText Then
CC.Title = "Tell your life story in 250 words or less."
End If
End Select
End Sub

Private Sub Document_ContentControlOnExit(ByVal CC As ContentControl, Cancel
As Boolean)
Dim i As Long
Select Case CC.Tag
Case Is = "LifeStory"
i = CC.Range.ComputeStatistics(wdStatisticWords)
If i > 250 Then
CC.Title = "Too many words. Shorten the story."
Cancel = True
Else
CC.Title = i & " words. A Pulitzer Prize!"
End If
End Select
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top