PDA

View Full Version : 'Submit' button



PeteB
05-20-2021, 10:58 AM
I have a Word form where fields have been created using Developer content controls (some fields are 'required'). Could someone please advise a block of VBA code that would disable the Submit button, and show a message box, pending completion of previously unfilled 'required' fields, and thereafter e-mailing the form from any e-mail client.

My understanding of VBA code is at novice level.

Any assistance would be appreciated.

PeteB

gmayor
05-29-2021, 04:20 AM
Not sure what you tried, but the following should work. It assumes your button is CommandButton1
Change the titles of the controls to check as required


Private Sub CommandButton1_Click()
Dim oCC As ContentControl
For Each oCC In ActiveDocument.ContentControls
Select Case oCC.Title
Case "Field 1 Title", "Field 2 Title" 'The titles of the required controls separated by commas
If oCC.ShowingPlaceholderText = True Then
oCC.Range.Select
MsgBox "Complete the field", vbCritical
Exit Sub
End If
Case Else
End Select
Next oCC
'rest of submit button code goes here
End Sub