PDA

View Full Version : [SOLVED:] Slideshow Shuffle/Randomizer keeps removing ALL background color



just_bri
07-27-2017, 08:43 PM
Hello. :)

I have MS Office 2016. I made some PowerPoint flashcards for class, and I assigned a different background color for each chapter. I want the slides shuffled, so I used a "slideshow randomizer" macro I found online...but it removes ALL of the background colors.

I discovered that if you manually cut a slide -- and then use Paste Special: Keep Source Formatting -- the slide remained unchanged. Is there a way to add this command to a macro?

Here's the shuffle/randomizer code I've been using. I'm assuming the last line needs to be changed somehow.

Thanks in advance for any help! :):

Sub sort_rand()
'CODE TAKEN FROM: pptfaq. com/FAQ00429_Randomize_the_order_of_a_PowerPoint_presentation.htm
Dim i As Integer
Dim myvalue As Integer
Dim islides As Integer
islides = ActivePresentation.Slides.Count
For i = 1 To ActivePresentation.Slides.Count
myvalue = Int((i * Rnd) + 1)
ActiveWindow.ViewType = ppViewSlideSorter
ActivePresentation.Slides(myvalue).Select
ActiveWindow.Selection.Cut
ActivePresentation.Slides(islides - 1).Select
ActiveWindow.View.Paste
Next


End Sub

John Wilson
07-27-2017, 11:40 PM
It is possible in 2016 to call Paste source format from vba but you would be better just moving slides.


Sub Shuffle()
Dim L As Integer
Dim iCount As Integer
Dim iFrom As Integer
Dim iTo As Integer
iCount = ActivePresentation.Slides.Count
For L = 1 To iCount * 2
Randomize
iFrom = Int(Rnd * iCount) + 1
Randomize
iTo = Int(Rnd * iCount) + 1
ActivePresentation.Slides(iFrom).MoveTo (iTo)
Next L
End Sub

just_bri
07-28-2017, 05:25 AM
Thanks! It works perfectly! I added your name + URL to the comments section of the macro, as thanks. :)