Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
VB
Sub paras()
Dim iLower As Integer, iUpper As Integer, iCount As Integer, temp As String
 Dim p As word.Paragraph
 Dim txt As Variant
 Dim w As Integer
Dim str As String
Dim i As Integer
Dim j As Integer
Dim rng As String
Dim iparCount As Integer
Dim strArray As Range
Dim sArray
Dim sMyPara As String
w = ActiveDocument.Range.words.count
iparCount = ActiveDocument.Paragraphs.count
   For i = 1 To iparCount
          sMyPara = ActiveDocument.Paragraphs(i).Range.text

                 Set strArray = ActiveDocument.Paragraphs(i).Range
          sArray = Split(strArray, ",")
          iUpper = UBound(sArray)
           iLower = 1
           Dim bSorted As Boolean
           bSorted = False
           Do While Not bSorted
                bSorted = True
                For iCount = iLower To iUpper - 1
                str2 = StrComp(sArray(iCount), sArray(iCount + 1), vbTextCompare)
                     If str2 = 1 Then
                           temp = sArray(iCount + 1)
                           sArray(iCount + 1) = sArray(iCount)
                           sArray(iCount) = temp
                           bSorted = False
                     End If
                Next iCount
             iUpper = iUpper - 1

           Loop
            rng = sArray(iCount)
         Next i

 End Sub
Posted

1 solution

Because, apparently, strArray is a Range (it should be a String).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900