View Single Post
 
Old 08-01-2020, 04:06 PM
macropod's Avatar
macropod macropod is online now Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

A simpler field construction might also do the job:
{QUOTE{SET Data {MERGEFIELD ACCOUNT_NUMBER}}
{=MOD(INT(Data/100000000000),1000) \# 0}
{IF{REF Data }= "*1" 1 {IF{REF Data }= "*2" 2 {IF{REF Data }= "*3" 3 {IF{REF Data }= "*4" 4 {IF{REF Data }= "*5" 5 {IF{REF Data }= "*6" 6 {IF{REF Data }= "*7" 7 {IF{REF Data }= "*8" 8 {IF{REF Data }= "*9" 9 0}}}}}}}}}}

But, if it's a macro you want, it can be much simpler and faster than yours, too:
Code:
Sub LastFour()
Application.ScreenUpdating = False
ActiveDocument.Range.Find.Execute FindText:="[0-9]{12}([0-9]{4})", ReplaceWith:="\1", MatchWildcards:=True, Replace:=wdReplaceAll
Application.ScreenUpdating = True
End Sub
It's also not apparent why you pass 'oDoc As Document' to the macro, meaning it can't be run via Alt-F8, but don't then do anything with it.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote