I'm trying to achieve something very simple. To select the items of a bullet list, run a macro and have those items shuffled randomly. I never used VBA in MS-Word so I started with very small steps, but even those seem to be hard to follow. My strategy is to insert items one at a time. The text of each newly-added paragraph would be the text of a randomly selected item from the selection. When the number of added paragraphs equals the number of items selected, I start to remove the original items in the selection.
This is my initial draft. It doesn't perfectly replicate my strategy but I need answers about the basics to continue.
Sub test()
Dim pars As Paragraphs
Dim rng As Range
' The selection is items from a bullet list (4 items).
Set pars = Selection.Paragraphs
' I have to do that if I don't want to overwrite the last element, though it is never filled later.. why?
pars.Add
' Simulate some shuffling here..
pars.Add.Range.FormattedText = pars(2).Range.FormattedText
pars.Add.Range.FormattedText = pars(1).Range.FormattedText
pars.Add.Range.FormattedText = pars(3).Range.FormattedText
pars.Add.Range.FormattedText = pars(4).Range.FormattedText
' The total number of paragraphs should be 8..
MsgBox pars.Count
' Now remove the top 4 paragraphs to keep just the last ones I added..
For i = 1 To 4
pars(1).Range.Delete
Next i
' I should get a message with 4 in it, instead I'm getting 1.. why??
MsgBox pars.Count
End Sub
My question is: what is the flow of adding paragraphs? How can I remove paragraphs?