Ask Your Question
2

How to rearrange slides using Excel VBA?

asked 2023-01-21 11:00:00 +0000

nofretete gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-05-26 21:00:00 +0000

qstack gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-01-21 11:00:00 +0000

Seen: 10 times

Last updated: May 26 '22