I took a closer look to see what was going on, and it is because of that large number split in the code that that fragmentation is occurring. A quick Google search yielded some VB code that was a lot better at handling the conversion. I’ve made some very minor tweaks to have it run in VBA/Word, and put a subroutine on it to match the selection code amendment I posted above. I figured it would be better to fix the issue than to partially patch the result.

```
Sub ConvertNumberToWords()
'Select Content
Selection.MoveEndWhile Cset:="0123456789,.", Count:=wdForward
Selection.MoveStartWhile Cset:="0123456789,.", Count:=wdBackward
' Store the digits in a variable
Selection.TypeText Text:=WordNum(Trim(Selection.Text))
End Sub
Function WordNum(MyNumber As Double) As String
Numbers = Array("", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen")
Tens = Array("", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety")
Dim DecimalPosition As Integer, ValNo As Variant, StrNo As String
Dim NumStr As String, n As Integer, Temp1 As String, Temp2 As String
' This macro was written by Chris Mead - www.MeadInKent.co.uk
If Abs(MyNumber) > 999999999 Then
WordNum = "Value too large"
Exit Function
End If
' String representation of amount (excl decimals)
NumStr = Right("000000000" & Trim(Str(Int(Abs(MyNumber)))), 9)
ValNo = Array(0, Val(Mid(NumStr, 1, 3)), Val(Mid(NumStr, 4, 3)), Val(Mid(NumStr, 7, 3)))
For n = 3 To 1 Step -1 'analyse the absolute number as 3 sets of 3 digits
StrNo = Format(ValNo(n), "000")
If ValNo(n) > 0 Then
Temp1 = GetTens(Val(Right(StrNo, 2)))
If Left(StrNo, 1) <> "0" Then
Temp2 = Numbers(Val(Left(StrNo, 1))) & " hundred"
If Temp1 <> "" Then Temp2 = Temp2 & " and "
Else
Temp2 = ""
End If
If n = 3 Then
If Temp2 = "" And ValNo(1) + ValNo(2) > 0 Then Temp2 = "and "
WordNum = Trim(Temp2 & Temp1)
End If
If n = 2 Then WordNum = Trim(Temp2 & Temp1 & " thousand " & WordNum)
If n = 1 Then WordNum = Trim(Temp2 & Temp1 & " million " & WordNum)
End If
Next n
NumStr = Trim(Str(Abs(MyNumber)))
' Values after the decimal place
DecimalPosition = InStr(NumStr, ".")
Numbers(0) = "Zero"
If DecimalPosition > 0 And DecimalPosition < Len(NumStr) Then
Temp1 = " point"
For n = DecimalPosition + 1 To Len(NumStr)
Temp1 = Temp1 & " " & Numbers(Val(Mid(NumStr, n, 1)))
Next n
WordNum = WordNum & Temp1
End If
If Len(WordNum) = 0 Or Left(WordNum, 2) = " p" Then
WordNum = "Zero" & WordNum
End If
End Function
Function GetTens(TensNum As Integer) As String
Numbers = Array("", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen")
Tens = Array("", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety")
' Converts a number from 0 to 99 into text.
If TensNum <= 19 Then
GetTens = Numbers(TensNum)
Else
Dim MyNo As String
MyNo = Format(TensNum, "00")
GetTens = Tens(Val(Left(MyNo, 1))) & " " & Numbers(Val(Right(MyNo, 1)))
End If
End Function
```

For my testing it seems to do a much better job, dealing automatically with commas, fractional parts, including “and” in the correct places. The only things it misses out on from my quick tests is hyphentaion of some of the compound words and negative numbers.

Running `ConvertNumberToWords`

gave me the following conversions:

- 87,000,000 -> eighty seven million
- 87,000,001 -> eighty seven million and one
- 87,000,000 -> eighty seven million and eleven
- 87,654,321 -> eighty seven million six hundred and fifty four thousand three hundred and twenty one
- 0001 -> one
- 0011 -> eleven
- 0111 -> one hundred and eleven
- 1111 -> one thousand one hundred and eleven
- 321.456 -> three hundred and twenty one point four five six

Hopefully, that should give you a stronger solution.