Thread: [Solved] Some problems in this script
View Single Post
 
Old 05-15-2017, 03:38 AM
eduzs eduzs is offline Windows 10 Office 2010 32bit
Expert
 
Join Date: May 2017
Posts: 266
eduzs is on a distinguished road
Default

I've found a solution myself.

For the 1st problem, I didn't found a solution, just stop the code if Selection.Range.Paragraphs.Count = ActiveDocument.Paragraphs.Count

Code:
If oPars.Count > 1 And Selection.Range.Paragraphs.Count < ActiveDocument.Paragraphs.Count Then
    Selection.Sort SortOrder:=wdSortOrderAscending
Else
    MsgBox "Não há seleção válida para classificar!", vbCritical, "  ERRO!"
    Exit Sub
End If
For the 2nd problem:

Code:
        If oPar2.Range.Text = oPar1.Range.Text Then
            i = i + 1
            If DelRep = 1 Then
                oPar2.Range.Delete
            Else
                Set oPar2 = oPar1.Next
                Exit Do
            End If
        Else
            Exit Do
        End If
Now I can I can now choose if I want numbering and/or exclude duplicates.

Thanks
Reply With Quote