Macro Kills Slide Timings and a Looping Question



A while ago I posted a question seeking a way to play a slideshow that's
located on a network share on several pcs simultaneously while maintaining
the capacity to update the slideshow "on the fly" and have those changes
reflected in the slideshow while it runs. The specifics can be found in this

I believe I've found a way to accomplish this by using two presentations.
The first one contains a macro that opens the second one in "read only" mode,
runs it, exits it, closes that window, then restarts the process all over
again. Here's the code...

Sub StartShow()
Presentations.Open FileName:="Z:\XXXXX.ppt", ReadOnly:=msoTrue
With ActivePresentation.SlideShowSettings
.ShowType = ppShowTypeKiosk
.LoopUntilStopped = msoFalse
.ShowWithNarration = msoFalse
.ShowWithAnimation = msoFalse
.RangeType = ppShowAll
.AdvanceMode = ppSlideShowUseSlideTimings
.PointerColor.RGB = RGB(Red:=255, Green:=0, Blue:=0)
End With
End Sub

The problem I'm having is when I run the macro with the Exit and Close
commands active the slide timings are squashed, the entire presentation (my
test presentation is 9 slides timed at 6 seconds each) runs in approximately
one second. If I comment out the Exit and Close commands (as shown above)
the timings work perfectly. Why does this happen and how can i fix it?

Secondly, While I need the loop, I also want to be able to stop it if the
need arises. When I tested the macro with the DO/LOOP enabled I wasn't able
to stop it with ESC or CTRL+BREAK. I had to use task manager to kill
PowerPoint completely. I THINK this was because the loop was running faster
than I could hit the keys to stop it but I'm not sure and am looking for some
feedback on continuous looping and breaking loops.

Your help is appreciated!
E. Cahall


Thanks for replying.

Steve Rindsberg said:
I'm probably using the wrong terms for this but ... Windows can run several processes at once;
in this case your VBA macro is running in one process, the slide show in another.

The VBA launches the slide show (which in Windows is an independent process) then goes on to run
whatever commands come next. Since the next commands tell the slide show to quit, that's what
happens. At least I think that's what's going on; but I'm not sure why your whole show's life
should pass before your eyes in that brief interval.

Multi-tasking, yes. That's what I thought was happening but I wasn't
Seems like you need another way of triggering the show to quit and restart.
How can you determine when this is necessary?

Your question is a good one, and that's where I'm stumped.

If the show was a fixed number of slides (y) showing for a fixed number of
seconds each (z), then the show could be triggered to quit after (y times z)
amount time elapsed. Unfortunately the number of slides isn't fixed and
can't be. The number of slides in the show at any given moment is dependant
on the amount of information that needs to be shared at that moment. Here's
a possible scenario: Life in the City is rolling along quietly so there are
only two or three slides showing, the "home" slide and two reminders about
upcoming training events. Suddenly all heck breaks loose, we have both a
robbery and a hit and run. A few more slides are added to the show with
information about the incidents and the suspects being sought. A few hours
later the creeps are caught (our cops are good), and we receive notification
that one of our officers is being recognized for a special achievement. The
show is updated again, the "bad guy" slides are removed and a new one about
the officer's award is added .

See my dilema? Do you have any ideas? Sometimes a person with a different
perspective on a situation can help.
Try including one or more DoEvents statements in your loop. That tells VBA to give Windows some
clock cycles to do its normal housekeeping, respond to user input, that kind of thing.

You can also use the Sleep API call to put your loop to sleep for a while, then wake up again
(and consume no cpu time in the interim).

Put your macro to Sleep

I've never written a DoEvent. Would you have any examples of some I could
see to get me going? I'm concerned that the things that might be required
to solve this are all going to be dependant on knowing how much time the show
needs to run.

One more thing...
I used the Linking and Looping tutorials from That works great
with regards to the timings and looping, but when go to I open the slave
slideshow (so I can add/remove slides) while it's running, I'm only allowed
to open it "read only", which defeats its purpose. Do you have any ideas?



That sounds like it would work, but it also sounds like it's above my coding
abilities. My deadline for completing this is running out. Can you refer me
to any resources where I could find some sample code to use as I teach this
to myself?

Another thought I had is: I used TAJ Simmon's trick of linking master/slave
presentations. This worked in all areas except being able to update the
slave presentation. When we try to open the slave we're prompted to open it
"read only". Do you know of a work-around for that? I tried this because I
had read in other threads about people having updated their presenetations
and the master presentation would re-read the slave (linked) each time it
looped. I wondered if it would work (I was always under the assumption that
the master was actuallly opening the slave which would render the slave
uneditable), I was right.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question