![]() |
|
#1
|
|||
|
|||
![]()
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 |
![]() |
Tags |
autoformat, formating |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
aditya_bokade | Word VBA | 28 | 11-13-2021 10:48 PM |
![]() |
Esgrimidor | Word VBA | 7 | 03-16-2017 01:02 PM |
![]() |
Jow | Word VBA | 4 | 09-15-2016 04:06 AM |
![]() |
Stacy | Excel | 2 | 09-12-2014 07:03 AM |
Macro to insert WordArt characters | Jennifer Murphy | Word VBA | 1 | 02-25-2014 03:10 AM |