?
Solved

Trouble looping through PowerPoint slides in ActivePresentation if I delete along the way

Posted on 2014-11-14
2
Medium Priority
?
227 Views
Last Modified: 2014-11-14
In my macro, I gather parameters for types of slides to keep, then I want to iterate through a deck of 123 slides and keep only those that match the parameters.  

So I'm going through and deleting slides that don't match the parameters.  I know I can't do from slide = 1 to activepresentation.slides.count, because then if you delete any along the way, you'll eventually get beyond the original count.  I tried the old reverse loop from activepresentation.slides.count to 1 step =1, but same thing happens when I delete a slide, it skips slides.  Appears that the slide index numbering shifts each time the number of slides changes.  I've tried for each myslide in activepresentation.slides, but same thing happens.  The act of deleting a slide messes up whatever pointer is being used.

I want to make sure I examine every slide, but not sure how to do that.  Maybe go through every slide, building an array of slide titles to be deleted, then delete them all at the end of the iteration?  There must be a more elegant solution.

Appreciate any help.
0
Comment
Question by:Bryce Bassett
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 2000 total points
ID: 40442159
for i = activepresentation.slides.count to 1 step -1 (I assume you meant "-1", not "=1") should work. I've done that before.

Could you post your code, and maybe a sample PowerPoint presentation.
0
 

Author Closing Comment

by:Bryce Bassett
ID: 40442197
Phillip:

Yes I did mean -1.  I just tried it again and it works.  So I must have been doing something wrong.

Thanks
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In all recent versions of PowerPoint it is possible to trigger animations. This means the animation takes place when a certain shape is clicked. This allows you to run animation “on demand” and outwith the normal sequence of mouse cl…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
This video teaches viewers how to add simple and professional themes to their slides.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question