title: Word 2016 VBA to shuffle numbered lists
body: <p>change the order of all numbered lists in the test, ie the macro looks for the start of a new numbered list, selects all items in the list, changes the order of the items and then moves over to the next numbered list.
  My Code</p>
  <pre><code>       Sub Shuffle()
  
          Dim li As List, rng As Range, random As Integer, nbr As Integer
          Application.ScreenUpdating = False
           Randomize
          For Each li In ActiveDocument.Lists
          nbr = li.CountNumberedItems
          ' Run along all items in list and swap with a random one from 
   the same list
    For a_counter = 1 To nbr
      ' Make sure the item is not swapped with itself, that would fail
   again:
          random = CInt((nbr - 1) * Rnd + 1)
      If random = a_counter Then GoTo again
  
      ' add a new paragraph as temporary place holder. This is so that we can keep the paragraph with its formatting intact.
      Set rng = li.Range.Paragraphs.Add.Range
      rng.FormattedText = li.Range.Paragraphs(random).Range.FormattedText
  
      ' swap the items
      li.Range.Paragraphs(random).Range.FormattedText = 
     li.Range.Paragraphs(a_counter).Range.FormattedText
      li.Range.Paragraphs(a_counter).Range.FormattedText = 
       li.Range.Paragraphs(nbr + 1).Range.FormattedText
  
      ' remove the temporary paragraph we added
     li.Range.Paragraphs(nbr + 1).Range.Delete
  Next a_counter
     Next
    Application.ScreenUpdating = True
  End Sub
  </code></pre>
  <p>After running this code I get runtime 4505 erroru.</p>
  <p>Example:</p>
  <p>Original:</p>
  <p>===== Start: ========</p>
  <p>Question 1 What answer is correct?</p>
  <p>Answer 1
  Answer 2
  Answer 3</p>
  <p>The macro should create this:</p>
  <p>======Start========</p>
  <p>Question 1 What answer is correct?</p>
  <p>Answer 3
  Answer 1
  Answer 2</p>