View Single Post
 
Old 02-28-2024, 08:15 AM
gmaxey gmaxey is offline Windows 10 Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Btw if every variable field in your form is a content control and every one needs to be filled in, you don't need to list the titles. Something like:


Code:
Sub ScratchMacro()
'A basic Word Macro coded by Gregory K. Maxey
Dim oCC As ContentControl
Dim oRng As Range
Dim strMsg As String
  For Each oCC In ActiveDocument.ContentControls
    If oCC.ShowingPlaceholderText Then
      If oRng Is Nothing Then
        Set oRng = oCC.Range
        oRng.Select
        strMsg = "One or more content controls is blank. Please enter data in the following CCs:" & vbCr & vbCr & oCC.Title & vbCr
      Else
        strMsg = strMsg & oCC.Title & vbCr
      End If
    End If
  Next oCC
  If strMsg = vbNullString Then strMsg = "Form complete.  Thank you."
  MsgBox strMsg, vbOKOnly, "REPORT"
lbl_Exit:
  Exit Sub
End Sub
should do.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote