title: I want to run a VBA code when opening a Power point presentation
body: <p>I am trying to figure out how i can shuffle the slides in one of my power point presentations when the presentation is opened.</p>
  
  <p>I have the code, but trying to find out how to make it work as power point do not have event handlers. I have tried different solutions but cant get it to work.</p>
  
  <p>I have tried with auto_open add-ins and also different codes but with no luck, thankful for any assistance</p>
  
  <p>The code i want to run when the presentation is opened up by a user:</p>
  
  <p>Sub shuffleRange()</p>
  
  <pre><code>Dim Iupper As Integer
  Dim ilower As Integer
  Dim ifrom As Integer
  Dim Ito As Integer
  Dim i As Integer
  
  Iupper = 21
  ilower = 2
  
  If Iupper &gt; ActivePresentation.Slides.Count Or ilower &lt; 1 Then GoTo Err
  
  For i = 1 To 2 * Iupper
  Randomize
  ifrom = Int((Iupper - ilower + 1) * Rnd + ilower)
  Ito = Int((Iupper - ilower + 1) * Rnd + ilower)
  ActivePresentation.Slides(ifrom).MoveTo (Ito)
  
  Next i
  
  Exit Sub
  </code></pre>
  
  <p>Err:
      MsgBox " Shuffle failed", vbCritical</p>
  
  <p>End Sub</p>