Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-29-2024, 04:21 AM
viewtost viewtost is offline Macro to check the data in a content control box Windows 10 Macro to check the data in a content control box Office 2019
Advanced Beginner
Macro to check the data in a content control box
 
Join Date: Jul 2021
Posts: 35
viewtost is on a distinguished road
Default

Quote:
Originally Posted by gmaxey View Post
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.
Hi Greg,

Many thanks. It works!

However, my question about listing the titles. Do you mean that the macro captures the content control titles without the need to list them here? Ie. I just have to give them a name in the Word file but I don't have to add those names to the code?
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Use VBA to show text when content control check box is checked kvrieze Word VBA 1 08-19-2023 03:11 AM
MsgBox launch when a Check Box Content Control is clicked wolfgrrl Word VBA 1 06-21-2019 12:13 PM
Macro to check the data in a content control box Check box content control to show text when checked Strogg Word 3 02-10-2019 11:45 AM
Check Box Content Control when checked users are presented with an option cryder Word 0 01-07-2016 05:11 AM
Macro to check the data in a content control box Replace checkbox symbol with check box content control canadansk Word VBA 5 04-01-2015 08:21 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:12 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft