Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-25-2022, 01:36 PM
gmaxey gmaxey is offline Make a field required Windows 10 Make a field required Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,636
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

In every Word document VB Project "ThisDocument" module there is an event:


Here, I have applied the tag "ManNum" to CCs requiring and numerical input and "ManText" to those requiring a text input.


Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
  Select Case ContentControl.Tag
    Case "ManText"
      If ContentControl.ShowingPlaceholderText Then
        MsgBox "This field requires a numeric response.", vbInformation + vbOKOnly, "INPUT REQUIRED"
        Cancel = True
      End If

    Case "ManNum"
      If Not IsNumeric(ContentControl.Range.Text) Then
        MsgBox "This field requires a numeric response.", vbInformation + vbOKOnly, "INPUT REQUIRED"
        Cancel = True
      End If
  End Select
lbl_Exit:
  Exit Sub
End Sub

__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Make a field required how to make a template with field and mailmerge to work together in protected mode pjkon Mail Merge 1 06-10-2019 04:35 PM
How To Make 2013 Populate To Field abraxis Outlook 2 08-10-2018 06:41 AM
Make a field required How to make a Check Box Form Field red if not checked? CarlCR Word Tables 3 07-12-2016 08:35 PM
Make a field required How to make a SEQ field show up in cross references? Roscoe Word 5 06-01-2016 01:39 PM
make text form field active dependent on dropdown Glenn0004 Word VBA 1 06-23-2015 06:13 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:59 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