A family of Microsoft word processing software products for creating web, email, and print documents.
DO NOT change the name of the macro. There should be only one ContentControlOnExit routine, and it should have the Document_ prefix, not anything else. This macro is an "event handler", one that runs whenever Word detects that the active cursor is about to exit from any content control in the active document.
The proper way to work with multiple content controls in the same document is to determine which content control is being exited, and do whatever is necessary for that control. The identity of the current content control is passed into the macro in the parameter named "ContentControl" (shown in bold here).*
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
The usual way to set up for multiple controls is to give each content control in the document a unique title and/ or tag value in its Properties dialog. Then the beginning of the code in the ContentControlOnExit routine can do something like this:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Select Case ContentControl.Tag
Case "Name"
'do something with the Name control
Case "Address"
'do something different with the Address control
Case "Phone"
'do something else with the Phone control
Case Else
' do nothing
Exit Sub
End Select
End Sub
A different circumstance is when you have one set of controls that all need to be treated the same way, and another set of controls in the same document that don't need to be treated at all. Then the first set should all have the same tag value, and the other set don't need to have any tag value. The test at the start of the ContentControlOnExit routine can be simply
If ContentControl.Tag <> "treat_this" Then Exit Sub
' if the tag is "treat_this", then execute the rest of the code
___
* I don't like the practice of naming a variable the same as a standard data type, but this is the way VBA automatically creates the ContentControl event handlers. I prefer to rename the variable to just "CC",
Private Sub Document_ContentControlOnExit(ByVal CC As ContentControl, Cancel As Boolean)
and then use CC as the variable in the rest of the code.