View Single Post
 
Old 12-21-2020, 05:16 PM
gmaxey gmaxey is offline Windows 10 Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,600
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

My fault, you need to use result (not range.text) and to format using alphacharacters, I think something like this:

Code:
Sub FormatInput()
Dim oFF As FormField
  Set oFF = ActiveDocument.FormFields("Text1") 'Your formfield bookmark name.
    If Not oFF.Range.Text Like "????-???-????" Then
       If Len(oFF.Range.Text) = 11 Then
         oFF.Result = Left(oFF.Result, 4) & "-" & Mid(oFF.Result, 5, 3) & "-" & Right(oFF.Result, 4)
       Else
         MsgBox "Please enter an eleven digit ID"
     End If
   End If
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote