Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-21-2020, 05:16 PM
gmaxey gmaxey is offline Formatting ID numbers to insert dashes in between some characters Windows 10 Formatting ID numbers to insert dashes in between some characters Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
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
Reply

Tags
autoformat, formating



Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting ID numbers to insert dashes in between some characters How to insert paragraph character after every 500 characters? aditya_bokade Word VBA 28 11-13-2021 10:48 PM
Formatting ID numbers to insert dashes in between some characters Insert text longer 254 characters in word Esgrimidor Word VBA 7 03-16-2017 01:02 PM
Formatting ID numbers to insert dashes in between some characters Insert more than 500 characters on FormField Word by VBA Jow Word VBA 4 09-15-2016 04:06 AM
Formatting ID numbers to insert dashes in between some characters Is there a quick way to remove the dashes and parentheses from phone numbers? 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

Other Forums: Access Forums

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