View Single Post
 
Old 01-10-2022, 04:38 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,164
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

This concept appears to work IF a heading is the trigger for each block of pages (ie a paragraph which has an outline level other than body text).
Code:
Sub RandomSortOfChap()
  Dim aPar As Paragraph
  'Add random numbers on headings
  For Each aPar In ActiveDocument.Paragraphs
    If aPar.Range.ParagraphFormat.OutlineLevel <> wdOutlineLevelBodyText Then
      aPar.Range.InsertBefore Left(Rnd(1) * 100000, 4) & vbTab
    End If
  Next aPar
  'Now sort based on the random number
  ActiveWindow.ActivePane.View.Type = wdOutlineView
  ActiveWindow.View.ShowHeading 5     'show five levels of headings
  Selection.Sort FieldNumber:="Paragraphs", SortFieldType:=wdSortFieldAlphanumeric
  ActiveWindow.ActivePane.View.Type = wdPrintView
  'And remove the numbers
  ActiveDocument.Range.Select
  WordBasic.ToolsBulletsNumbers Replace:=0, Type:=1, Remove:=1
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote