Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can use the following steps to rearrange slides using Excel VBA:

  1. Open PowerPoint and create a new presentation.
  2. In Excel, open the Visual Basic Editor (VBE) by pressing ALT + F11.
  3. In the VBE, insert a new module by right-clicking on the Project Explorer and selecting "Insert > Module".
  4. At the top of the new module, enter the following code to start a new subroutine:

Sub RearrangeSlides()

  1. Next, add the code to set up a PowerPoint object and open the presentation:

Dim pptApp As PowerPoint.Application Dim pptPres As PowerPoint.Presentation

Set pptApp = New PowerPoint.Application Set pptPres = pptApp.Presentations.Open("c:\path\to\presentation.pptx")

  1. Now, add the code to rearrange the slides. For example, to move the second slide to the end of the presentation, use the following code:

pptPres.Slides(2).MoveTo pptPres.Slides.Count

  1. You can rearrange multiple slides by repeating this code for each slide you want to move.

  2. Finally, add the code to save and close the presentation:

pptPres.Save pptPres.Close pptApp.Quit

  1. End the subroutine by adding the following line of code:

End Sub

  1. To run the code, go back to Excel and click on the "Run" button or press F5.

Your PowerPoint presentation should now have the slides rearranged according to your code.