View Single Post
 
Old 02-27-2024, 04:07 PM
Charles Kenyon Charles Kenyon is offline Windows 11 Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,470
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Quote:
Many thanks, it works. What if I have more content controls with different titles. For instance another one called "Department".
In a separate procedure have an Array that holds the names.
Cycle through those names calling the check control macro with each name. In the procedure that has the names, assign the variable strName to each name in turn and use:
Code:
CheckContentControl(strName)
Change the macro to something like:
Code:
Sub CheckContentControl(strName)
   ' Andrew Lockton
  ' https://www.msofficeforums.com/word-vba/52145-macro-check-data-content-control-box.html
'

   Dim aCC As ContentControl, bEmpty As Boolean
  For Each aCC In ActiveDocument.SelectContentControlsByTitle(strName)
    bEmpty = aCC.ShowingPlaceholderText
    If bEmpty Then
      MsgBox "The Content Control " & strName & " is Empty"
    Else
      MsgBox "The Content Control  " & strName & " has content"
    End If
  Next
End Sub
Reply With Quote