(sigh)
The code below is in a module in the attached document.
Theory is you select a set of paragraphs and the macro reverses the sequence.
It seems to work for my purposes, but I know how you guys love picking my code to shreds, so knock yourselves out.
I'm busy playing with my mouse-wheel to see what else it can do.
Code: Select all
Sub ReverseSequenceParagraphs()
Dim lngParagraphsCount As Long ' Needed for the last loop, since SELECTION.paragraphs.count will have changed by then
lngParagraphsCount = Selection.Paragraphs.Count
Dim rngOldText As Range ' So we can delete the original text at end-of-run
Set rngOldText = Selection.Range
Dim rngNewtext As Range ' So we can identify a starting-point for the re-sorted text
Set rngNewtext = Selection.Range
rngNewtext.Start = rngNewtext.End ' Dump the re-sorted text one character beyond the original text
Dim rngAr() As Range ' Holds the paragraph ranges for re-arrangement
ReDim rngAr(lngParagraphsCount - 1)
Dim lngAr As Long
For lngAr = 1 To lngParagraphsCount ' Load the original configuration
Set rngAr(lngAr - 1) = Selection.Paragraphs(lngAr).Range
Next lngAr
For lngAr = 1 To Int(lngParagraphsCount / 2) ' up to, but not including, the mid-way point
Dim rngSpare As Range ' Swap top-and-bottom, working towards, but not up to, the centre
Set rngSpare = rngAr(lngAr - 1)
Set rngAr(lngAr - 1) = rngAr(lngParagraphsCount - lngAr)
Set rngAr(lngParagraphsCount - lngAr) = rngSpare
Next lngAr
rngNewtext.Select ' Prepare to write the new sequence
For lngAr = 1 To lngParagraphsCount
Selection.TypeText (rngAr(lngAr - 1))
Next lngAr
rngOldText.Delete ' Delete the old sequence
End Sub