How does macro select current-slide during View Show? REVISED

G

Guest

I want users to be able to Hide a slide while they are seeing it during View
Show. I'm making educational flashcards and want the user to be able to hide
a card that they know well and, therefore, don't want to view it again
during their current View Show session.

I've a macro and button that works - but only for the specific slide I
referenced in
the macro. I need the macro to refer to whatever slide is the user is
viewing at the time. The code that works for Hidding slide #1:

ActivePresentation.Slides(1).SlideShowTransition.Hidden = msoTrue

The user also has to exit View Show and restart View Show for the slide to
be hidden, but that inconvenience is OK.

I'll then make a macro to unHide all slides whenever the user wants to go
thru all the flashcards again.

Thanks in advance
 
G

Guest

Yes that worked great. I'm a VBA novice so it took me a while to figure out
what to do with the code. For the benefit of other novices, here's what
seems to work: I went to http://officeone.mvps.org/vba/get_active_slide.html
and copied the entire code to my PowerPoint VBA module. I don't think I use
or need the two subs TestDesignWindow() or TestSlideShowWindow() but I kept
them anyway.

Then I guessed that the key code i needed was in the second sub as follows:

(GetActiveSlide(SlideShowWindows(1)).SlideIndex)

I then inserted the above string in place of the "1" in the following code:

ActivePresentation.Slides(1).SlideShowTransition.Hidden = msoTrue

The above code worked to Hide a slide while I was in View Show, but the "1"
means the code would only hide slide #1 instead of the slide I was viewing.

So, my final, working code is as follows:

Sub HideThisSlideDuringPresentation()
' ' Macro recorded 6/21/2007 by Hail Family
'

ActivePresentation.Slides((GetActiveSlide(SlideShowWindows(1)).SlideIndex)).SlideShowTransition.Hidden = msoTrue
End Sub


Thank you.
 
B

Bill Dilworth

Close. This line will hide the slide that is being shown when the macro is
fired.

ActivePresentation _
.Slides _
(ActivePresentation _
.SlideShowWindow _
.View.CurrentShowPosition) _
.SlideShowTransition _
.Hidden = msoTrue

--
Bill Dilworth
A proud member of the Microsoft PPT MVP Team
Users helping fellow users.
http://billdilworth.mvps.org
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
vestprog2@ Please read the PowerPoint FAQ pages.
yahoo. They answer most of our questions.
com www.pptfaq.com
..
 
G

Guest

Bill, your code worked like my previous code. That is, while I'm in a View
Show sesssion, I click my macro button and then I Alt-Tab to the Normal or
Slide Sorter View and can see that the slide is now marked as Hidden - but
when I Alt-Tab back into the View Show session, the slide continues to show.
When I end the session and restart View Show, the slide is hidden as
expected. Any way to get the slide to hide without having to restart View
Show? Thank you.
 
B

Bill Dilworth

So add a line of code that advances the slide show to the next un-hidden
slide.

Slideshowwindows(1).view.gotoslide (x) <= where x is the slide you want to
go to.


You may want to add a small routine to look at current slide + 1 to see if
that slide is hidden. If it is, try x + 2 and so on until the end of the
presentation.
--
Bill Dilworth
A proud member of the Microsoft PPT MVP Team
Users helping fellow users.
http://billdilworth.mvps.org
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
vestprog2@ Please read the PowerPoint FAQ pages.
yahoo. They answer most of our questions.
com www.pptfaq.com
..
 
G

Guest

Bill,

I see I've two remaining problems:

#1. Make newly Hidden slides disappear during current View Show session.
As noted earlier: after the user clicks the macro button to hide the slide
currently displayed in View Show, the slide remains visible in the View Show
instead of dropping out of the current View Show session.

#2. After restarting View Show, happily, the hidden slides do remain hidden
except for the following two situations:

A. When I'm past a Hidden slide but then backup using the back-arrow key,
the hidden slide appears in it's slide-sorter order. I suspect this behavior
is default PowerPoint behavior and, thus, not much we can do to change it.

B. When I click my macro "Random" button with the following code, the
hidden slides appear along with the unhidden slides:

ActivePresentation.SlideShowWindow _
.View.GotoSlide Int(Rnd * _
ActivePresentation.Slides.Count) + 1

I'd try out your code
Slideshowwindows(1).view.gotoslide (x)
to fix the above problems, but I don't know how to even start modifying it
to select only the unhidden slides.

Thank you for getting me this far. Appreciate anything else you might
suggest.

John Hail
 
D

David M. Marcovitz

This is really cool, but your project is starting to get complicated.
There are several possible ways to do what you want to do.

(1) What if you moved all the slides to the end of the show and hid them
at the same time. Then, keep track of how many unhidden slides you have
and randomly jump between 1 and that number. I think this might solve
many of your problems.

(2) If you want to keep the slides in the same order, you would either
have to track which ones are hidden, check which ones are hidden, or keep
trying until you land on an unhidden slide (beware of what happens if no
slides are unhidden). The GotoSlide method doesn't care if the slides are
hidden, so you have to check before you use that to make sure the slide
you are going to isn't hidden. I could imagine a loop that keeps checking
over and over again until it finds an unhidden slide. For a small
slideshow this would be OK as long as you are sure that there is at least
one unhidden slide.

(3) Instead of hiding the slides, you could set their transitions to
automatically advance to the next slide after 0 seconds. If you ever
landed on an unavailable slide, it would automatically go to the next
slide. Of course, this would bias what would be chosen by the number of
unavailable slides before it. For example if you have 100 slides and only
slides 99 and 100 are available, you have a 99% chance of landing on
slide 99 or one of the slides that takes you to 99, and you would only
have a 1% chance of landing on side 100.

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
S

Steve Rindsberg

(2) If you want to keep the slides in the same order, you would either
have to track which ones are hidden, check which ones are hidden, or keep
trying until you land on an unhidden slide (beware of what happens if no
slides are unhidden). The GotoSlide method doesn't care if the slides are
hidden, so you have to check before you use that to make sure the slide
you are going to isn't hidden. I could imagine a loop that keeps checking
over and over again until it finds an unhidden slide. For a small
slideshow this would be OK as long as you are sure that there is at least
one unhidden slide.

This should help:

Show me the next unhidden slide
http://www.pptfaq.com/FAQ00876.htm

It's a function that returns the index of the next unhidden slide after any
arbitrary slide or zero if there is no unhidden slide.

In this case, you'd do something like:

Dim lNextSlide as Long
Dim lStartingSlideIndex as Long

' Set lStartingSlideIndex to index of current slide in view
' then:

lNextSlide = NextUnhiddenSlide(lStartingSlideIndex As Long)

' Is there a next slide that's unhidden?
If lNextSlide > 0 Then ' there is, there is!
SlideShowWindows(1).View.GoToSlide(lNextSlide)
' or whatever GoTo code you're using
End If
 
G

Guest

Thank you Steve, the Hide and Unhide Peekaboo code works great. 2 more
questions:

1. Thanks also for the Random Slide code via MSDN but I don't know VBE well
enough to correctly paste it into PowerPoint's VBE. For example, what is
the text string to start it as a Function? Also, VBE gives an error on the
following line:

lNextSlide = NextUnhiddenSlide(lStartingSlideIndex As Long)

The error box says "Compile Error: [line break] Expected: list separator or )"

2. Is there a good way to post my PowerPoint template file for others to
use and maybe improve? I'm building the file for non-programmer Users (like
me) with premade buttons for Peekaboos, RandomNextSlide, etc to make slides
with flashcard-like functions.

John
 
S

Steve Rindsberg

The back story ... John emailed me about a few missing features in the code
here:

Peekaboo Text: Use VBA to make text appear and disappear
http://www.pptfaq.com/FAQ00662.htm

I added a few new routines, John tried 'em out and ...
Thank you Steve, the Hide and Unhide Peekaboo code works great. 2 more
questions:

1. Thanks also for the Random Slide code via MSDN but I don't know VBE well
enough to correctly paste it into PowerPoint's VBE. For example, what is
the text string to start it as a Function?

Rats... I've lost the link to that. There are several of these so let me know
which you're working with. Or just pop the code in here.

Also, VBE gives an error on the
following line:

lNextSlide = NextUnhiddenSlide(lStartingSlideIndex As Long)

The error box says "Compile Error: [line break] Expected: list separator or )"

Hard to say exactly, but you need to assign a value to lStartingSlideIndex
before calling the function.

For example, if you're currently on slide 12:

lStartingSlideIndex = 12
lNextSlide = NextUnhiddenSlide(lStartingSlideIndex As Long)

Bill's code will give you the index of the current slide; that's what you'd want
to assign to lStartingSlideIndex.
2. Is there a good way to post my PowerPoint template file for others to
use and maybe improve? I'm building the file for non-programmer Users (like
me) with premade buttons for Peekaboos, RandomNextSlide, etc to make slides
with flashcard-like functions.

If it's relatively small and you wouldn't mind writing up a set of instructions
for it, I could put it up on the FAQ with a link from the page with the code.
That'd make a nice addition.
 
G

Guest

I've emailed Steve my current PowerPoint flashcard template file to post
where others can download it and maybe improve/correct it. The file
includes the following:
- Instructions for non-programmers who want to create flashcard-like slides.
- Instructions for end-users who will view the flashcard-like Slide Show.
- A few premade Peekaboo boxes to copy&paste where needed.
- Buttons to Hide All Peekaboos and to then Unhide them all.
- Button to hide slides so you can skip over material you've learned.
- Button to go to a Random slide (but this Random function still displays
Hidden slides instead of skipping them).
- A credits page showing where I've gotten the key macro/code so far.

Thank you all for suggesting code for going-to random slides but I don't
know how to sew the pieces together. For me, the next-generation macros are
as follows:

1. Go To A Random Slide, but without displaying a hidden slide.

2. When a User clicks the Hide Slide buttion, make the slide immediately
disappear. My current Hide Slide does mark the slide as Hidden but the slide
remains displayed during the current View Show session.

Thanks again.

John Hail
 
S

Steve Rindsberg

I've emailed Steve my current PowerPoint flashcard template file to post
where others can download it and maybe improve/correct it.

And Steve hasn't had a chance to do anything with it yet - hang in there. <g>


The file
 

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

Top