G
Greg Maxey
I posted the following in the DocManagement group to format words like Smith as S-M-I-T-H.
Sub myFormat()
Dim oRng As Range
Dim oChr As Word.Range
Set oRng = Selection.Range
oRng.Text = UCase(oRng.Text)
oRng.MoveEndUntil Cset:="ABCDEFGHIJKLMNOPQRSTUVWXYZ", _
Count:=wdBackward
Set oChr = oRng.Characters.First
Do
oChr.InsertAfter "-"
Set oChr = oChr.Next
Loop Until oChr = oRng.Characters.Last
End Sub
I thought that I could use Cset:="[A-Z]"
but it didn't work. I suppose that there is nothign wrong with "ABCD..." but was curious to know if there is a better way.
Thanks
Sub myFormat()
Dim oRng As Range
Dim oChr As Word.Range
Set oRng = Selection.Range
oRng.Text = UCase(oRng.Text)
oRng.MoveEndUntil Cset:="ABCDEFGHIJKLMNOPQRSTUVWXYZ", _
Count:=wdBackward
Set oChr = oRng.Characters.First
Do
oChr.InsertAfter "-"
Set oChr = oChr.Next
Loop Until oChr = oRng.Characters.Last
End Sub
I thought that I could use Cset:="[A-Z]"
but it didn't work. I suppose that there is nothign wrong with "ABCD..." but was curious to know if there is a better way.
Thanks