Thread: [Solved] Reverse Paragraph List Macro
View Single Post
 
Old 08-16-2021, 05:50 AM
Sark Sark is offline Windows XP Office 2003
Novice
 
Join Date: Apr 2017
Posts: 25
Sark is on a distinguished road
Default

That was embarressingly simple.
CorelDraw uses ActiveSelectionRange. I tried a dozen variations of this without success. Thanks for the advice it's much appreciated.

For anyone who comes across this thread in the future, below is the ammended version. I've also included a message box warning when the user forgets to select any text.


Code:
Sub ReverseOrderOfParagraphs()
    Dim tmpTable As Table
    Dim rg As Range

    InSelection = False
    If Selection.Type = wdSelectionIP Then
        MsgBox "Nothing Selected"
   End
End If

    Set tmpTable = Selection.Range.ConvertToTable(Separator:=wdSeparateByParagraphs)
    With tmpTable
        .Columns.Add BeforeColumn:=.Columns(1)
       
        Set rg = .Cell(1, 1).Range
        rg.End = rg.End - 1
        rg.Fields.Add Range:=rg, Type:=wdFieldSequence, Text:="a"
        rg.Cells(1).Range.Copy
       
        .Columns(1).Select
        Selection.Paste
        Selection.Fields.Update
       
        .Sort ExcludeHeader:=False, FieldNumber:=1, SortOrder:=wdSortOrderDescending
        .Columns(1).Delete
        .ConvertToText

    End With
End Sub
Reply With Quote