Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
developer
active.documents
automation
binary.file_format
clipboard.dde
com.add_ins
hosting.controls
internet_other
office.sdks
officedev
officedev.other
outlook.forms
outlook.vba
smarttags
vba
web.components
  
 
date: Fri, 18 Jul 2008 05:10:03 -0700,    group: microsoft.public.office.developer.vba        back       


forward and backward slide transitions .. programming different so   
I have a certain sound play each time the ppt slide show transitions forwards 
from one slide to the following one. The same sound plays when I transition 
in reverse, ie from one slide to the previous slide. Using standard 
functions, is it possible to set different sounds when transitioning forward 
and in reverse? 

If not, can a macro be written that runs each time there is a slide 
transition, detects whether the transition is forward or backward, and 
depending on the direction plays either one of two sounds?
TIA .... Greg
date: Fri, 18 Jul 2008 05:10:03 -0700   author:   gvm

Re: forward and backward slide transitions .. programming different so   
In article , Gvm wrote:
> I have a certain sound play each time the ppt slide show transitions forwards 
> from one slide to the following one. The same sound plays when I transition 
> in reverse, ie from one slide to the previous slide. Using standard 
> functions, is it possible to set different sounds when transitioning forward 
> and in reverse? 

No, afraid not.

> If not, can a macro be written that runs each time there is a slide 
> transition, detects whether the transition is forward or backward, and 
> depending on the direction plays either one of two sounds?

Probably so. You'd need to implement an event handler in an add-in:

Make PPT respond to events
http://www.pptfaq.com/FAQ00004.htm

It could trap slide changes and by storing the previous slide's Index in a 
global or static variable, compare that with the current slide to work out if 
you're moving forward or backward.

I'm not sure exactly when the event fires though ... on or after slide change. 
That might make a difference.


--
Steve Rindsberg, PPT MVP
PPT FAQ:  www.pptfaq.com
PPTools:  www.pptools.com
================================================
date: Fri, 18 Jul 2008 11:03:45 EDT   author:   Steve Rindsberg

Re: forward and backward slide transitions .. programming differen   
Steve, thanks but I need more help to get started. Can you assist further 
please? TIA ... Greg

"Steve Rindsberg" wrote:

> In article , Gvm wrote:
> > I have a certain sound play each time the ppt slide show transitions forwards 
> > from one slide to the following one. The same sound plays when I transition 
> > in reverse, ie from one slide to the previous slide. Using standard 
> > functions, is it possible to set different sounds when transitioning forward 
> > and in reverse? 
> 
> No, afraid not.
> 
> > If not, can a macro be written that runs each time there is a slide 
> > transition, detects whether the transition is forward or backward, and 
> > depending on the direction plays either one of two sounds?
> 
> Probably so. You'd need to implement an event handler in an add-in:
> 
> Make PPT respond to events
> http://www.pptfaq.com/FAQ00004.htm
> 
> It could trap slide changes and by storing the previous slide's Index in a 
> global or static variable, compare that with the current slide to work out if 
> you're moving forward or backward.
> 
> I'm not sure exactly when the event fires though ... on or after slide change. 
> That might make a difference.
> 
> 
> --
> Steve Rindsberg, PPT MVP
> PPT FAQ:  www.pptfaq.com
> PPTools:  www.pptools.com
> ================================================
> 
> 
>
date: Sat, 19 Jul 2008 22:03:00 -0700   author:   gvm

Re: forward and backward slide transitions .. programming differen   
In article , Gvm wrote:
> Steve, thanks but I need more help to get started. Can you assist further 
> please? TIA ... Greg

If I can, sure, but if you've never done any VBA/VB programming before, this isn't 
really a starter project.  

> 
> "Steve Rindsberg" wrote:
> 
> > In article , Gvm wrote:
> > > I have a certain sound play each time the ppt slide show transitions forwards 
> > > from one slide to the following one. The same sound plays when I transition 
> > > in reverse, ie from one slide to the previous slide. Using standard 
> > > functions, is it possible to set different sounds when transitioning forward 
> > > and in reverse? 
> > 
> > No, afraid not.
> > 
> > > If not, can a macro be written that runs each time there is a slide 
> > > transition, detects whether the transition is forward or backward, and 
> > > depending on the direction plays either one of two sounds?
> > 
> > Probably so. You'd need to implement an event handler in an add-in:
> > 
> > Make PPT respond to events
> > http://www.pptfaq.com/FAQ00004.htm
> > 
> > It could trap slide changes and by storing the previous slide's Index in a 
> > global or static variable, compare that with the current slide to work out if 
> > you're moving forward or backward.
> > 
> > I'm not sure exactly when the event fires though ... on or after slide change. 
> > That might make a difference.
> > 
> > 
> > --
> > Steve Rindsberg, PPT MVP
> > PPT FAQ:  www.pptfaq.com
> > PPTools:  www.pptools.com
> > ================================================
> > 
> > 
> >
>

--
Steve Rindsberg, PPT MVP
PPT FAQ:  www.pptfaq.com
PPTools:  www.pptools.com
================================================
date: Sun, 20 Jul 2008 13:59:16 EDT   author:   Steve Rindsberg

Re: forward and backward slide transitions .. programming differen   
I understand your point Steve; my VBA experience is in Excel and so its use 
with ppt is what's new for me ... Greg

"Steve Rindsberg" wrote:

> In article , Gvm wrote:
> > Steve, thanks but I need more help to get started. Can you assist further 
> > please? TIA ... Greg
> 
> If I can, sure, but if you've never done any VBA/VB programming before, this isn't 
> really a starter project.  
> 
> > 
> > "Steve Rindsberg" wrote:
> > 
> > > In article , Gvm wrote:
> > > > I have a certain sound play each time the ppt slide show transitions forwards 
> > > > from one slide to the following one. The same sound plays when I transition 
> > > > in reverse, ie from one slide to the previous slide. Using standard 
> > > > functions, is it possible to set different sounds when transitioning forward 
> > > > and in reverse? 
> > > 
> > > No, afraid not.
> > > 
> > > > If not, can a macro be written that runs each time there is a slide 
> > > > transition, detects whether the transition is forward or backward, and 
> > > > depending on the direction plays either one of two sounds?
> > > 
> > > Probably so. You'd need to implement an event handler in an add-in:
> > > 
> > > Make PPT respond to events
> > > http://www.pptfaq.com/FAQ00004.htm
> > > 
> > > It could trap slide changes and by storing the previous slide's Index in a 
> > > global or static variable, compare that with the current slide to work out if 
> > > you're moving forward or backward.
> > > 
> > > I'm not sure exactly when the event fires though ... on or after slide change. 
> > > That might make a difference.
> > > 
> > > 
> > > --
> > > Steve Rindsberg, PPT MVP
> > > PPT FAQ:  www.pptfaq.com
> > > PPTools:  www.pptools.com
> > > ================================================
> > > 
> > > 
> > >
> >
> 
> --
> Steve Rindsberg, PPT MVP
> PPT FAQ:  www.pptfaq.com
> PPTools:  www.pptools.com
> ================================================
> 
> 
>
date: Sun, 20 Jul 2008 17:11:00 -0700   author:   gvm

Re: forward and backward slide transitions .. programming differen   
In article , Gvm wrote:
> I understand your point Steve; my VBA experience is in Excel and so its use 
> with ppt is what's new for me ... Greg

That's bigtime different from no experience in Office/VBA at all. ;-)

You'll want to read the tutorial at the link below.  It explains how to set up an event 
handler.  For most purposes, you'll want to save this and the associated code as an 
Add-in (PPA).

Once the event handler is active, it'll run code of your choosing (the code in the 
individual event routines or code called from there) when certain events happen.

Since there's only a SlideShowNextSlide event, you'll need to see if it fires even when 
you move to slides other than the one following the current one.  If not, it may not be 
possible to do what you're after, at least not the way I'm thinking of.

At the end of the routine you fire with this event, you'd update a global 
LastSlideViewed variable to the current .SlideIndex.  Next time into the routine you 
compare the current slide number with LastSlideViewed.  If 

If SlideShowWindows(1).View.Slide.SlideIndex > LastSlideViewed Then
   ' we moved forward
Else
   ' we moved backward
End If


> > > > In article , Gvm wrote:
> > > > > I have a certain sound play each time the ppt slide show transitions forwards 
> > > > > from one slide to the following one. The same sound plays when I transition 
> > > > > in reverse, ie from one slide to the previous slide. Using standard 
> > > > > functions, is it possible to set different sounds when transitioning forward 
> > > > > and in reverse? 
> > > > 
> > > > No, afraid not.
> > > > 
> > > > > If not, can a macro be written that runs each time there is a slide 
> > > > > transition, detects whether the transition is forward or backward, and 
> > > > > depending on the direction plays either one of two sounds?
> > > > 
> > > > Probably so. You'd need to implement an event handler in an add-in:
> > > > 
> > > > Make PPT respond to events
> > > > http://www.pptfaq.com/FAQ00004.htm
> > > > 
> > > > It could trap slide changes and by storing the previous slide's Index in a 
> > > > global or static variable, compare that with the current slide to work out if 
> > > > you're moving forward or backward.
> > > > 
> > > > I'm not sure exactly when the event fires though ... on or after slide change. 
> > > > That might make a difference.
> > > > 
> > > > 
> > > > --
> > > > Steve Rindsberg, PPT MVP
> > > > PPT FAQ:  www.pptfaq.com
> > > > PPTools:  www.pptools.com
> > > > ================================================
> > > > 
> > > > 
> > > >
> > >
> > 
> > --
> > Steve Rindsberg, PPT MVP
> > PPT FAQ:  www.pptfaq.com
> > PPTools:  www.pptools.com
> > ================================================
> > 
> > 
> >
>

--
Steve Rindsberg, PPT MVP
PPT FAQ:  www.pptfaq.com
PPTools:  www.pptools.com
================================================
date: Mon, 21 Jul 2008 10:58:48 EDT   author:   Steve Rindsberg

Re: forward and backward slide transitions .. programming differen   
Excellent, thanks Steve ... Greg

"Steve Rindsberg" wrote:

> In article , Gvm wrote:
> > I understand your point Steve; my VBA experience is in Excel and so its use 
> > with ppt is what's new for me ... Greg
> 
> That's bigtime different from no experience in Office/VBA at all. ;-)
> 
> You'll want to read the tutorial at the link below.  It explains how to set up an event 
> handler.  For most purposes, you'll want to save this and the associated code as an 
> Add-in (PPA).
> 
> Once the event handler is active, it'll run code of your choosing (the code in the 
> individual event routines or code called from there) when certain events happen.
> 
> Since there's only a SlideShowNextSlide event, you'll need to see if it fires even when 
> you move to slides other than the one following the current one.  If not, it may not be 
> possible to do what you're after, at least not the way I'm thinking of.
> 
> At the end of the routine you fire with this event, you'd update a global 
> LastSlideViewed variable to the current .SlideIndex.  Next time into the routine you 
> compare the current slide number with LastSlideViewed.  If 
> 
> If SlideShowWindows(1).View.Slide.SlideIndex > LastSlideViewed Then
>    ' we moved forward
> Else
>    ' we moved backward
> End If
> 
> 
> > > > > In article , Gvm wrote:
> > > > > > I have a certain sound play each time the ppt slide show transitions forwards 
> > > > > > from one slide to the following one. The same sound plays when I transition 
> > > > > > in reverse, ie from one slide to the previous slide. Using standard 
> > > > > > functions, is it possible to set different sounds when transitioning forward 
> > > > > > and in reverse? 
> > > > > 
> > > > > No, afraid not.
> > > > > 
> > > > > > If not, can a macro be written that runs each time there is a slide 
> > > > > > transition, detects whether the transition is forward or backward, and 
> > > > > > depending on the direction plays either one of two sounds?
> > > > > 
> > > > > Probably so. You'd need to implement an event handler in an add-in:
> > > > > 
> > > > > Make PPT respond to events
> > > > > http://www.pptfaq.com/FAQ00004.htm
> > > > > 
> > > > > It could trap slide changes and by storing the previous slide's Index in a 
> > > > > global or static variable, compare that with the current slide to work out if 
> > > > > you're moving forward or backward.
> > > > > 
> > > > > I'm not sure exactly when the event fires though ... on or after slide change. 
> > > > > That might make a difference.
> > > > > 
> > > > > 
> > > > > --
> > > > > Steve Rindsberg, PPT MVP
> > > > > PPT FAQ:  www.pptfaq.com
> > > > > PPTools:  www.pptools.com
> > > > > ================================================
> > > > > 
> > > > > 
> > > > >
> > > >
> > > 
> > > --
> > > Steve Rindsberg, PPT MVP
> > > PPT FAQ:  www.pptfaq.com
> > > PPTools:  www.pptools.com
> > > ================================================
> > > 
> > > 
> > >
> >
> 
> --
> Steve Rindsberg, PPT MVP
> PPT FAQ:  www.pptfaq.com
> PPTools:  www.pptools.com
> ================================================
> 
> 
>
date: Wed, 23 Jul 2008 19:32:17 -0700   author:   gvm

Re: forward and backward slide transitions .. programming differen   
Steve,
I have based my macro on Shyam Pillai's sub that reports the index number in 
a message box after each slide transition. Use of the sub shows that the 
variable "index" reports the correct slide number transitioning both forwards 
and backwards. Since Nextslide runs before moving to the next slide and I 
read that "SlideIndex" is the index of the next slide, I thought the test for 
whether transition is forward or back is simply a comparison of Shyam's 
"index" and "SlideIndex". 

So what follows is my adaptation of Shyam's macro. I expect there are a 
number of problems in it, but the first is that the sub loops on the first 
slide, ie the message box pos up repeatedly and it is necessary to terminate 
ppt to get out of the loop. I would appreciate your help, TIA .. Greg

Sub Auto_NextSlide(Index As Long)
Dim CurrentSlide As Long
CurrentSlide = Index
MsgBox "Slide No:" & Index
    If ActivePresentation.SlideShowWindow.View.Slide.SlideIndex > 
CurrentSlide Then
' we moved forward
    ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
    .ImportFromFile "c:\program files\microsoft office\media\laser.wav"
Else
' we moved backward
    ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
    .ImportFromFile "c:\program files\microsoft office\media\type.wav"
End If
End Sub



"Steve Rindsberg" wrote:

> In article , Gvm wrote:
> > I have a certain sound play each time the ppt slide show transitions forwards 
> > from one slide to the following one. The same sound plays when I transition 
> > in reverse, ie from one slide to the previous slide. Using standard 
> > functions, is it possible to set different sounds when transitioning forward 
> > and in reverse? 
> 
> No, afraid not.
> 
> > If not, can a macro be written that runs each time there is a slide 
> > transition, detects whether the transition is forward or backward, and 
> > depending on the direction plays either one of two sounds?
> 
> Probably so. You'd need to implement an event handler in an add-in:
> 
> Make PPT respond to events
> http://www.pptfaq.com/FAQ00004.htm
> 
> It could trap slide changes and by storing the previous slide's Index in a 
> global or static variable, compare that with the current slide to work out if 
> you're moving forward or backward.
> 
> I'm not sure exactly when the event fires though ... on or after slide change. 
> That might make a difference.
> 
> 
> --
> Steve Rindsberg, PPT MVP
> PPT FAQ:  www.pptfaq.com
> PPTools:  www.pptools.com
> ================================================
> 
> 
>
date: Sat, 26 Jul 2008 04:44:01 -0700   author:   gvm

Re: forward and backward slide transitions .. programming differen   
Give this a try instead:

First, you need to add this to the event class if it's not already there:

Private Sub PPTEvent_SlideShowNextSlide(ByVal wn As SlideShowWindow)
    Call Auto_NextSlide(wn)
End Sub

Note that the parameter passed to the event is the slide show window, not the slide 
index; in your code module, this:

Sub Auto_NextSlide(wn As SlideShowWindow)
' Note again that the slide show window is the parameter,
' not slide index

    ' declare this as static so its value 
    ' is retained between invocations of the sub
    Static LastSlide As Long
    
    Dim CurrentSlide As Long
    
    CurrentSlide = wn.View.Slide.SlideIndex
    
    MsgBox "Slide No: " & CurrentSlide
    
    If LastSlide = 0 Then
        ' we just started the show
        ' add special case code here or ignore
        '
        ' we'll ignore:
        LastSlide = CurrentSlide
        Exit Sub
    End If
    
    If CurrentSlide > LastSlide Then
    ' we moved forward
        ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
        .ImportFromFile "c:\program files\microsoft office\media\laser.wav"
    Else
    ' we moved backward
        ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
        .ImportFromFile "c:\program files\microsoft office\media\type.wav"
    End If

    LastSlide = CurrentSlide

End Sub


In article , Gvm wrote:
> Steve,
> I have based my macro on Shyam Pillai's sub that reports the index number in 
> a message box after each slide transition. Use of the sub shows that the 
> variable "index" reports the correct slide number transitioning both forwards 
> and backwards. Since Nextslide runs before moving to the next slide and I 
> read that "SlideIndex" is the index of the next slide, I thought the test for 
> whether transition is forward or back is simply a comparison of Shyam's 
> "index" and "SlideIndex". 
> 
> So what follows is my adaptation of Shyam's macro. I expect there are a 
> number of problems in it, but the first is that the sub loops on the first 
> slide, ie the message box pos up repeatedly and it is necessary to terminate 
> ppt to get out of the loop. I would appreciate your help, TIA .. Greg
> 
> Sub Auto_NextSlide(Index As Long)
> Dim CurrentSlide As Long
> CurrentSlide = Index
> MsgBox "Slide No:" & Index
>     If ActivePresentation.SlideShowWindow.View.Slide.SlideIndex > 
> CurrentSlide Then
> ' we moved forward
>     ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
>     .ImportFromFile "c:\program files\microsoft office\media\laser.wav"
> Else
> ' we moved backward
>     ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
>     .ImportFromFile "c:\program files\microsoft office\media\type.wav"
> End If
> End Sub
> 
> "Steve Rindsberg" wrote:
> 
> > In article , Gvm wrote:
> > > I have a certain sound play each time the ppt slide show transitions forwards 
> > > from one slide to the following one. The same sound plays when I transition 
> > > in reverse, ie from one slide to the previous slide. Using standard 
> > > functions, is it possible to set different sounds when transitioning forward 
> > > and in reverse? 
> > 
> > No, afraid not.
> > 
> > > If not, can a macro be written that runs each time there is a slide 
> > > transition, detects whether the transition is forward or backward, and 
> > > depending on the direction plays either one of two sounds?
> > 
> > Probably so. You'd need to implement an event handler in an add-in:
> > 
> > Make PPT respond to events
> > http://www.pptfaq.com/FAQ00004.htm
> > 
> > It could trap slide changes and by storing the previous slide's Index in a 
> > global or static variable, compare that with the current slide to work out if 
> > you're moving forward or backward.
> > 
> > I'm not sure exactly when the event fires though ... on or after slide change. 
> > That might make a difference.
> > 
> > 
> > --
> > Steve Rindsberg, PPT MVP
> > PPT FAQ:  www.pptfaq.com
> > PPTools:  www.pptools.com
> > ================================================
> > 
> > 
> >
>

--
Steve Rindsberg, PPT MVP
PPT FAQ:  www.pptfaq.com
PPTools:  www.pptools.com
================================================
date: Fri, 01 Aug 2008 10:34:46 EDT   author:   Steve Rindsberg

Re: forward and backward slide transitions .. programming differen   
Thanks Steve. 
I updated the macro code you provided me in 
VBAProject(test.ppt)/Modules/Module 1 and created and pasted the Private Sub 
PPTEvent subroutine in VBAProject(test.ppt)/Class Modules/Class 1. 

AutoEvents is enabled within ppt but the event and/or macro is not firing. 
Have I interpreted your instructions correctly? 

I noticed that if I select Tools/Macro/Macros from test.ppt, no macros are 
listed as being present in test.ppt. Is this expected, or is it an indication 
of why I have a problem?

Thanks again Steve, I appreciate your patience with me ... Greg



"Steve Rindsberg" wrote:

> Give this a try instead:
> 
> First, you need to add this to the event class if it's not already there:
> 
> Private Sub PPTEvent_SlideShowNextSlide(ByVal wn As SlideShowWindow)
>     Call Auto_NextSlide(wn)
> End Sub
> 
> Note that the parameter passed to the event is the slide show window, not the slide 
> index; in your code module, this:
> 
> Sub Auto_NextSlide(wn As SlideShowWindow)
> ' Note again that the slide show window is the parameter,
> ' not slide index
> 
>     ' declare this as static so its value 
>     ' is retained between invocations of the sub
>     Static LastSlide As Long
>     
>     Dim CurrentSlide As Long
>     
>     CurrentSlide = wn.View.Slide.SlideIndex
>     
>     MsgBox "Slide No: " & CurrentSlide
>     
>     If LastSlide = 0 Then
>         ' we just started the show
>         ' add special case code here or ignore
>         '
>         ' we'll ignore:
>         LastSlide = CurrentSlide
>         Exit Sub
>     End If
>     
>     If CurrentSlide > LastSlide Then
>     ' we moved forward
>         ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
>         .ImportFromFile "c:\program files\microsoft office\media\laser.wav"
>     Else
>     ' we moved backward
>         ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
>         .ImportFromFile "c:\program files\microsoft office\media\type.wav"
>     End If
> 
>     LastSlide = CurrentSlide
> 
> End Sub
> 
> 
> In article , Gvm wrote:
> > Steve,
> > I have based my macro on Shyam Pillai's sub that reports the index number in 
> > a message box after each slide transition. Use of the sub shows that the 
> > variable "index" reports the correct slide number transitioning both forwards 
> > and backwards. Since Nextslide runs before moving to the next slide and I 
> > read that "SlideIndex" is the index of the next slide, I thought the test for 
> > whether transition is forward or back is simply a comparison of Shyam's 
> > "index" and "SlideIndex". 
> > 
> > So what follows is my adaptation of Shyam's macro. I expect there are a 
> > number of problems in it, but the first is that the sub loops on the first 
> > slide, ie the message box pos up repeatedly and it is necessary to terminate 
> > ppt to get out of the loop. I would appreciate your help, TIA .. Greg
> > 
> > Sub Auto_NextSlide(Index As Long)
> > Dim CurrentSlide As Long
> > CurrentSlide = Index
> > MsgBox "Slide No:" & Index
> >     If ActivePresentation.SlideShowWindow.View.Slide.SlideIndex > 
> > CurrentSlide Then
> > ' we moved forward
> >     ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> >     .ImportFromFile "c:\program files\microsoft office\media\laser.wav"
> > Else
> > ' we moved backward
> >     ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> >     .ImportFromFile "c:\program files\microsoft office\media\type.wav"
> > End If
> > End Sub
> > 
> > "Steve Rindsberg" wrote:
> > 
> > > In article , Gvm wrote:
> > > > I have a certain sound play each time the ppt slide show transitions forwards 
> > > > from one slide to the following one. The same sound plays when I transition 
> > > > in reverse, ie from one slide to the previous slide. Using standard 
> > > > functions, is it possible to set different sounds when transitioning forward 
> > > > and in reverse? 
> > > 
> > > No, afraid not.
> > > 
> > > > If not, can a macro be written that runs each time there is a slide 
> > > > transition, detects whether the transition is forward or backward, and 
> > > > depending on the direction plays either one of two sounds?
> > > 
> > > Probably so. You'd need to implement an event handler in an add-in:
> > > 
> > > Make PPT respond to events
> > > http://www.pptfaq.com/FAQ00004.htm
> > > 
> > > It could trap slide changes and by storing the previous slide's Index in a 
> > > global or static variable, compare that with the current slide to work out if 
> > > you're moving forward or backward.
> > > 
> > > I'm not sure exactly when the event fires though ... on or after slide change. 
> > > That might make a difference.
> > > 
> > > 
> > > --
> > > Steve Rindsberg, PPT MVP
> > > PPT FAQ:  www.pptfaq.com
> > > PPTools:  www.pptools.com
> > > ================================================
> > > 
> > > 
> > >
> >
> 
> --
> Steve Rindsberg, PPT MVP
> PPT FAQ:  www.pptfaq.com
> PPTools:  www.pptools.com
> ================================================
> 
> 
>
date: Sat, 2 Aug 2008 02:37:01 -0700   author:   gvm

Re: forward and backward slide transitions .. programming differen   
In article , Gvm wrote:
> Thanks Steve. 
> I updated the macro code you provided me in 
> VBAProject(test.ppt)/Modules/Module 1 and created and pasted the Private Sub 
> PPTEvent subroutine in VBAProject(test.ppt)/Class Modules/Class 1. 
> 
> AutoEvents is enabled within ppt but the event and/or macro is not firing. 
> Have I interpreted your instructions correctly? 

Possibly, but remember that within a PPT, every time you edit the macro or get an error 
message, it's likely going to disable event trapping, so you have to re-set the event 
trap.

> I noticed that if I select Tools/Macro/Macros from test.ppt, no macros are 
> listed as being present in test.ppt. Is this expected, or is it an indication 
> of why I have a problem?

Not sure ... is test.ppt the file where your macros are stored?

> 
> Thanks again Steve, I appreciate your patience with me ... Greg
> 
> "Steve Rindsberg" wrote:
> 
> > Give this a try instead:
> > 
> > First, you need to add this to the event class if it's not already there:
> > 
> > Private Sub PPTEvent_SlideShowNextSlide(ByVal wn As SlideShowWindow)
> >     Call Auto_NextSlide(wn)
> > End Sub
> > 
> > Note that the parameter passed to the event is the slide show window, not the slide 
> > index; in your code module, this:
> > 
> > Sub Auto_NextSlide(wn As SlideShowWindow)
> > ' Note again that the slide show window is the parameter,
> > ' not slide index
> > 
> >     ' declare this as static so its value 
> >     ' is retained between invocations of the sub
> >     Static LastSlide As Long
> >     
> >     Dim CurrentSlide As Long
> >     
> >     CurrentSlide = wn.View.Slide.SlideIndex
> >     
> >     MsgBox "Slide No: " & CurrentSlide
> >     
> >     If LastSlide = 0 Then
> >         ' we just started the show
> >         ' add special case code here or ignore
> >         '
> >         ' we'll ignore:
> >         LastSlide = CurrentSlide
> >         Exit Sub
> >     End If
> >     
> >     If CurrentSlide > LastSlide Then
> >     ' we moved forward
> >         ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> >         .ImportFromFile "c:\program files\microsoft office\media\laser.wav"
> >     Else
> >     ' we moved backward
> >         ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> >         .ImportFromFile "c:\program files\microsoft office\media\type.wav"
> >     End If
> > 
> >     LastSlide = CurrentSlide
> > 
> > End Sub
> > 
> > 
> > In article , Gvm wrote:
> > > Steve,
> > > I have based my macro on Shyam Pillai's sub that reports the index number in 
> > > a message box after each slide transition. Use of the sub shows that the 
> > > variable "index" reports the correct slide number transitioning both forwards 
> > > and backwards. Since Nextslide runs before moving to the next slide and I 
> > > read that "SlideIndex" is the index of the next slide, I thought the test for 
> > > whether transition is forward or back is simply a comparison of Shyam's 
> > > "index" and "SlideIndex". 
> > > 
> > > So what follows is my adaptation of Shyam's macro. I expect there are a 
> > > number of problems in it, but the first is that the sub loops on the first 
> > > slide, ie the message box pos up repeatedly and it is necessary to terminate 
> > > ppt to get out of the loop. I would appreciate your help, TIA .. Greg
> > > 
> > > Sub Auto_NextSlide(Index As Long)
> > > Dim CurrentSlide As Long
> > > CurrentSlide = Index
> > > MsgBox "Slide No:" & Index
> > >     If ActivePresentation.SlideShowWindow.View.Slide.SlideIndex > 
> > > CurrentSlide Then
> > > ' we moved forward
> > >     ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> > >     .ImportFromFile "c:\program files\microsoft office\media\laser.wav"
> > > Else
> > > ' we moved backward
> > >     ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> > >     .ImportFromFile "c:\program files\microsoft office\media\type.wav"
> > > End If
> > > End Sub
> > > 
> > > "Steve Rindsberg" wrote:
> > > 
> > > > In article , Gvm wrote:
> > > > > I have a certain sound play each time the ppt slide show transitions forwards 
> > > > > from one slide to the following one. The same sound plays when I transition 
> > > > > in reverse, ie from one slide to the previous slide. Using standard 
> > > > > functions, is it possible to set different sounds when transitioning forward 
> > > > > and in reverse? 
> > > > 
> > > > No, afraid not.
> > > > 
> > > > > If not, can a macro be written that runs each time there is a slide 
> > > > > transition, detects whether the transition is forward or backward, and 
> > > > > depending on the direction plays either one of two sounds?
> > > > 
> > > > Probably so. You'd need to implement an event handler in an add-in:
> > > > 
> > > > Make PPT respond to events
> > > > http://www.pptfaq.com/FAQ00004.htm
> > > > 
> > > > It could trap slide changes and by storing the previous slide's Index in a 
> > > > global or static variable, compare that with the current slide to work out if 
> > > > you're moving forward or backward.
> > > > 
> > > > I'm not sure exactly when the event fires though ... on or after slide change. 
> > > > That might make a difference.
> > > > 
> > > > 
> > > > --
> > > > Steve Rindsberg, PPT MVP
> > > > PPT FAQ:  www.pptfaq.com
> > > > PPTools:  www.pptools.com
> > > > ================================================
> > > > 
> > > > 
> > > >
> > >
> > 
> > --
> > Steve Rindsberg, PPT MVP
> > PPT FAQ:  www.pptfaq.com
> > PPTools:  www.pptools.com
> > ================================================
> > 
> > 
> >
>

--
Steve Rindsberg, PPT MVP
PPT FAQ:  www.pptfaq.com
PPTools:  www.pptools.com
================================================
date: Sat, 02 Aug 2008 18:29:41 EDT   author:   Steve Rindsberg

Re: forward and backward slide transitions .. programming differen   
Steve, 
re your question "is test.ppt the file where your macros are stored?", the 
answer is I think so; - the macro is visible when I view the source code in 
VBAProject(test.ppt)/Modules/Module 1.

Re your point about having to reset the event handler: I disabled and 
re-enabled Auto Events inside ppt. Is that the way to reset the event trap? 
Doing so appears to have failed to make any difference - tne event handler / 
macro still doesn't fire.

kind regards ... Greg


"Steve Rindsberg" wrote:

> In article , Gvm wrote:
> > Thanks Steve. 
> > I updated the macro code you provided me in 
> > VBAProject(test.ppt)/Modules/Module 1 and created and pasted the Private Sub 
> > PPTEvent subroutine in VBAProject(test.ppt)/Class Modules/Class 1. 
> > 
> > AutoEvents is enabled within ppt but the event and/or macro is not firing. 
> > Have I interpreted your instructions correctly? 
> 
> Possibly, but remember that within a PPT, every time you edit the macro or get an error 
> message, it's likely going to disable event trapping, so you have to re-set the event 
> trap.
> 
> > I noticed that if I select Tools/Macro/Macros from test.ppt, no macros are 
> > listed as being present in test.ppt. Is this expected, or is it an indication 
> > of why I have a problem?
> 
> Not sure ... is test.ppt the file where your macros are stored?
> 
> > 
> > Thanks again Steve, I appreciate your patience with me ... Greg
> > 
> > "Steve Rindsberg" wrote:
> > 
> > > Give this a try instead:
> > > 
> > > First, you need to add this to the event class if it's not already there:
> > > 
> > > Private Sub PPTEvent_SlideShowNextSlide(ByVal wn As SlideShowWindow)
> > >     Call Auto_NextSlide(wn)
> > > End Sub
> > > 
> > > Note that the parameter passed to the event is the slide show window, not the slide 
> > > index; in your code module, this:
> > > 
> > > Sub Auto_NextSlide(wn As SlideShowWindow)
> > > ' Note again that the slide show window is the parameter,
> > > ' not slide index
> > > 
> > >     ' declare this as static so its value 
> > >     ' is retained between invocations of the sub
> > >     Static LastSlide As Long
> > >     
> > >     Dim CurrentSlide As Long
> > >     
> > >     CurrentSlide = wn.View.Slide.SlideIndex
> > >     
> > >     MsgBox "Slide No: " & CurrentSlide
> > >     
> > >     If LastSlide = 0 Then
> > >         ' we just started the show
> > >         ' add special case code here or ignore
> > >         '
> > >         ' we'll ignore:
> > >         LastSlide = CurrentSlide
> > >         Exit Sub
> > >     End If
> > >     
> > >     If CurrentSlide > LastSlide Then
> > >     ' we moved forward
> > >         ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> > >         .ImportFromFile "c:\program files\microsoft office\media\laser.wav"
> > >     Else
> > >     ' we moved backward
> > >         ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> > >         .ImportFromFile "c:\program files\microsoft office\media\type.wav"
> > >     End If
> > > 
> > >     LastSlide = CurrentSlide
> > > 
> > > End Sub
> > > 
> > > 
> > > In article , Gvm wrote:
> > > > Steve,
> > > > I have based my macro on Shyam Pillai's sub that reports the index number in 
> > > > a message box after each slide transition. Use of the sub shows that the 
> > > > variable "index" reports the correct slide number transitioning both forwards 
> > > > and backwards. Since Nextslide runs before moving to the next slide and I 
> > > > read that "SlideIndex" is the index of the next slide, I thought the test for 
> > > > whether transition is forward or back is simply a comparison of Shyam's 
> > > > "index" and "SlideIndex". 
> > > > 
> > > > So what follows is my adaptation of Shyam's macro. I expect there are a 
> > > > number of problems in it, but the first is that the sub loops on the first 
> > > > slide, ie the message box pos up repeatedly and it is necessary to terminate 
> > > > ppt to get out of the loop. I would appreciate your help, TIA .. Greg
> > > > 
> > > > Sub Auto_NextSlide(Index As Long)
> > > > Dim CurrentSlide As Long
> > > > CurrentSlide = Index
> > > > MsgBox "Slide No:" & Index
> > > >     If ActivePresentation.SlideShowWindow.View.Slide.SlideIndex > 
> > > > CurrentSlide Then
> > > > ' we moved forward
> > > >     ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> > > >     .ImportFromFile "c:\program files\microsoft office\media\laser.wav"
> > > > Else
> > > > ' we moved backward
> > > >     ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> > > >     .ImportFromFile "c:\program files\microsoft office\media\type.wav"
> > > > End If
> > > > End Sub
> > > > 
> > > > "Steve Rindsberg" wrote:
> > > > 
> > > > > In article , Gvm wrote:
> > > > > > I have a certain sound play each time the ppt slide show transitions forwards 
> > > > > > from one slide to the following one. The same sound plays when I transition 
> > > > > > in reverse, ie from one slide to the previous slide. Using standard 
> > > > > > functions, is it possible to set different sounds when transitioning forward 
> > > > > > and in reverse? 
> > > > > 
> > > > > No, afraid not.
> > > > > 
> > > > > > If not, can a macro be written that runs each time there is a slide 
> > > > > > transition, detects whether the transition is forward or backward, and 
> > > > > > depending on the direction plays either one of two sounds?
> > > > > 
> > > > > Probably so. You'd need to implement an event handler in an add-in:
> > > > > 
> > > > > Make PPT respond to events
> > > > > http://www.pptfaq.com/FAQ00004.htm
> > > > > 
> > > > > It could trap slide changes and by storing the previous slide's Index in a 
> > > > > global or static variable, compare that with the current slide to work out if 
> > > > > you're moving forward or backward.
> > > > > 
> > > > > I'm not sure exactly when the event fires though ... on or after slide change. 
> > > > > That might make a difference.
> > > > > 
> > > > > 
> > > > > --
> > > > > Steve Rindsberg, PPT MVP
> > > > > PPT FAQ:  www.pptfaq.com
> > > > > PPTools:  www.pptools.com
> > > > > ================================================
> > > > > 
> > > > > 
> > > > >
> > > >
> > > 
> > > --
> > > Steve Rindsberg, PPT MVP
> > > PPT FAQ:  www.pptfaq.com
> > > PPTools:  www.pptools.com
> > > ================================================
> > > 
> > > 
> > >
> >
> 
> --
> Steve Rindsberg, PPT MVP
> PPT FAQ:  www.pptfaq.com
> PPTools:  www.pptools.com
> ================================================
> 
> 
>
date: Sun, 3 Aug 2008 04:07:00 -0700   author:   gvm

Re: forward and backward slide transitions .. programming differen   
I missed something in your earlier post ... my bad

The line:

Dim cPPTObject As New cEventClass

assumes that you have a class named cEventClass

Try renaming your Class1 to that.


n article , Gvm wrote:
> Steve, 
> re your question "is test.ppt the file where your macros are stored?", the 
> answer is I think so; - the macro is visible when I view the source code in 
> VBAProject(test.ppt)/Modules/Module 1.
> 
> Re your point about having to reset the event handler: I disabled and 
> re-enabled Auto Events inside ppt. Is that the way to reset the event trap? 
> Doing so appears to have failed to make any difference - tne event handler / 
> macro still doesn't fire.
> 
> kind regards ... Greg
> 
> "Steve Rindsberg" wrote:
> 
> > In article , Gvm wrote:
> > > Thanks Steve. 
> > > I updated the macro code you provided me in 
> > > VBAProject(test.ppt)/Modules/Module 1 and created and pasted the Private Sub 
> > > PPTEvent subroutine in VBAProject(test.ppt)/Class Modules/Class 1. 
> > > 
> > > AutoEvents is enabled within ppt but the event and/or macro is not firing. 
> > > Have I interpreted your instructions correctly? 
> > 
> > Possibly, but remember that within a PPT, every time you edit the macro or get an error 
> > message, it's likely going to disable event trapping, so you have to re-set the event 
> > trap.
> > 
> > > I noticed that if I select Tools/Macro/Macros from test.ppt, no macros are 
> > > listed as being present in test.ppt. Is this expected, or is it an indication 
> > > of why I have a problem?
> > 
> > Not sure ... is test.ppt the file where your macros are stored?
> > 
> > > 
> > > Thanks again Steve, I appreciate your patience with me ... Greg
> > > 
> > > "Steve Rindsberg" wrote:
> > > 
> > > > Give this a try instead:
> > > > 
> > > > First, you need to add this to the event class if it's not already there:
> > > > 
> > > > Private Sub PPTEvent_SlideShowNextSlide(ByVal wn As SlideShowWindow)
> > > >     Call Auto_NextSlide(wn)
> > > > End Sub
> > > > 
> > > > Note that the parameter passed to the event is the slide show window, not the slide 
> > > > index; in your code module, this:
> > > > 
> > > > Sub Auto_NextSlide(wn As SlideShowWindow)
> > > > ' Note again that the slide show window is the parameter,
> > > > ' not slide index
> > > > 
> > > >     ' declare this as static so its value 
> > > >     ' is retained between invocations of the sub
> > > >     Static LastSlide As Long
> > > >     
> > > >     Dim CurrentSlide As Long
> > > >     
> > > >     CurrentSlide = wn.View.Slide.SlideIndex
> > > >     
> > > >     MsgBox "Slide No: " & CurrentSlide
> > > >     
> > > >     If LastSlide = 0 Then
> > > >         ' we just started the show
> > > >         ' add special case code here or ignore
> > > >         '
> > > >         ' we'll ignore:
> > > >         LastSlide = CurrentSlide
> > > >         Exit Sub
> > > >     End If
> > > >     
> > > >     If CurrentSlide > LastSlide Then
> > > >     ' we moved forward
> > > >         ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> > > >         .ImportFromFile "c:\program files\microsoft office\media\laser.wav"
> > > >     Else
> > > >     ' we moved backward
> > > >         ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> > > >         .ImportFromFile "c:\program files\microsoft office\media\type.wav"
> > > >     End If
> > > > 
> > > >     LastSlide = CurrentSlide
> > > > 
> > > > End Sub
> > > > 
> > > > 
> > > > In article , Gvm wrote:
> > > > > Steve,
> > > > > I have based my macro on Shyam Pillai's sub that reports the index number in 
> > > > > a message box after each slide transition. Use of the sub shows that the 
> > > > > variable "index" reports the correct slide number transitioning both forwards 
> > > > > and backwards. Since Nextslide runs before moving to the next slide and I 
> > > > > read that "SlideIndex" is the index of the next slide, I thought the test for 
> > > > > whether transition is forward or back is simply a comparison of Shyam's 
> > > > > "index" and "SlideIndex". 
> > > > > 
> > > > > So what follows is my adaptation of Shyam's macro. I expect there are a 
> > > > > number of problems in it, but the first is that the sub loops on the first 
> > > > > slide, ie the message box pos up repeatedly and it is necessary to terminate 
> > > > > ppt to get out of the loop. I would appreciate your help, TIA .. Greg
> > > > > 
> > > > > Sub Auto_NextSlide(Index As Long)
> > > > > Dim CurrentSlide As Long
> > > > > CurrentSlide = Index
> > > > > MsgBox "Slide No:" & Index
> > > > >     If ActivePresentation.SlideShowWindow.View.Slide.SlideIndex > 
> > > > > CurrentSlide Then
> > > > > ' we moved forward
> > > > >     ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> > > > >     .ImportFromFile "c:\program files\microsoft office\media\laser.wav"
> > > > > Else
> > > > > ' we moved backward
> > > > >     ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> > > > >     .ImportFromFile "c:\program files\microsoft office\media\type.wav"
> > > > > End If
> > > > > End Sub
> > > > > 
> > > > > "Steve Rindsberg" wrote:
> > > > > 
> > > > > > In article , Gvm wrote:
> > > > > > > I have a certain sound play each time the ppt slide show transitions forwards 
> > > > > > > from one slide to the following one. The same sound plays when I transition 
> > > > > > > in reverse, ie from one slide to the previous slide. Using standard 
> > > > > > > functions, is it possible to set different sounds when transitioning forward 
> > > > > > > and in reverse? 
> > > > > > 
> > > > > > No, afraid not.
> > > > > > 
> > > > > > > If not, can a macro be written that runs each time there is a slide 
> > > > > > > transition, detects whether the transition is forward or backward, and 
> > > > > > > depending on the direction plays either one of two sounds?
> > > > > > 
> > > > > > Probably so. You'd need to implement an event handler in an add-in:
> > > > > > 
> > > > > > Make PPT respond to events
> > > > > > http://www.pptfaq.com/FAQ00004.htm
> > > > > > 
> > > > > > It could trap slide changes and by storing the previous slide's Index in a 
> > > > > > global or static variable, compare that with the current slide to work out if 
> > > > > > you're moving forward or backward.
> > > > > > 
> > > > > > I'm not sure exactly when the event fires though ... on or after slide change. 
> > > > > > That might make a difference.
> > > > > > 
> > > > > > 
> > > > > > --
> > > > > > Steve Rindsberg, PPT MVP
> > > > > > PPT FAQ:  www.pptfaq.com
> > > > > > PPTools:  www.pptools.com
> > > > > > ================================================
> > > > > > 
> > > > > > 
> > > > > >
> > > > >
> > > > 
> > > > --
> > > > Steve Rindsberg, PPT MVP
> > > > PPT FAQ:  www.pptfaq.com
> > > > PPTools:  www.pptools.com
> > > > ================================================
> > > > 
> > > > 
> > > >
> > >
> > 
> > --
> > Steve Rindsberg, PPT MVP
> > PPT FAQ:  www.pptfaq.com
> > PPTools:  www.pptools.com
> > ================================================
> > 
> > 
> >
>

--
Steve Rindsberg, PPT MVP
PPT FAQ:  www.pptfaq.com
PPTools:  www.pptools.com
================================================
date: Sun, 03 Aug 2008 18:25:37 EDT   author:   Steve Rindsberg

Re: forward and backward slide transitions .. programming differen   
Thanks again Steve. re your advice "The line:
Dim cPPTObject As New cEventClass
assumes that you have a class named cEventClass
Try renaming your Class1 to that."

two things:
(1) How do I rename the Class1 module please? Obviously it is not as easy as 
right clicking and selecting Rename on the VBAProject(test.ppt)/Class 
Modules/Class 1 icon.
(2) Perhaps my code is incomplete because neither the statement "Dim 
cPPTObject As New cEventClass" nor cPPTObject is apparent in my code. I have 
pasted my code from both modules below for your inspection. Regards ... Greg
       Stored in: VBAProject(test.ppt)/Class Modules/Class 1....
Private Sub Class_Initialize()
End Sub
Private Sub PPTEvent_SlideShowNextSlide(ByVal wn As SlideShowWindow)
    Call Auto_NextSlide(wn)
End Sub

       And stored in VBAProject(test.ppt)/Modules/Module 1
Sub Auto_NextSlide(wn As SlideShowWindow)
' Note again that the slide show window is the parameter, not slide index
 ' declare this as static so its value is retained between invocations of 
the sub
    Static LastSlide As Long   
    Dim CurrentSlide As Long    
    CurrentSlide = wn.View.Slide.SlideIndex    
    MsgBox "Slide No: " & CurrentSlide
    
    If LastSlide = 0 Then
        ' we just started the show
        ' add special case code here or ignore
        '
        ' we'll ignore:
        LastSlide = CurrentSlide
        Exit Sub
    End If
    
    If CurrentSlide > LastSlide Then
    ' we moved forward
        ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
        .ImportFromFile "c:\program files\microsoft office\media\laser.wav"
    Else
    ' we moved backward
        ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
        .ImportFromFile "c:\program files\microsoft office\media\type.wav"
    End If

    LastSlide = CurrentSlide
End Sub


--------  end of code -----------
"Steve Rindsberg" wrote:

> I missed something in your earlier post ... my bad
> 
> The line:
> 
> Dim cPPTObject As New cEventClass
> 
> assumes that you have a class named cEventClass
> 
> Try renaming your Class1 to that.
> 
> 
> n article , Gvm wrote:
> > Steve, 
> > re your question "is test.ppt the file where your macros are stored?", the 
> > answer is I think so; - the macro is visible when I view the source code in 
> > VBAProject(test.ppt)/Modules/Module 1.
> > 
> > Re your point about having to reset the event handler: I disabled and 
> > re-enabled Auto Events inside ppt. Is that the way to reset the event trap? 
> > Doing so appears to have failed to make any difference - tne event handler / 
> > macro still doesn't fire.
> > 
> > kind regards ... Greg
> > 
> > "Steve Rindsberg" wrote:
> > 
> > > In article , Gvm wrote:
> > > > Thanks Steve. 
> > > > I updated the macro code you provided me in 
> > > > VBAProject(test.ppt)/Modules/Module 1 and created and pasted the Private Sub 
> > > > PPTEvent subroutine in VBAProject(test.ppt)/Class Modules/Class 1. 
> > > > 
> > > > AutoEvents is enabled within ppt but the event and/or macro is not firing. 
> > > > Have I interpreted your instructions correctly? 
> > > 
> > > Possibly, but remember that within a PPT, every time you edit the macro or get an error 
> > > message, it's likely going to disable event trapping, so you have to re-set the event 
> > > trap.
> > > 
> > > > I noticed that if I select Tools/Macro/Macros from test.ppt, no macros are 
> > > > listed as being present in test.ppt. Is this expected, or is it an indication 
> > > > of why I have a problem?
> > > 
> > > Not sure ... is test.ppt the file where your macros are stored?
> > > 
> > > > 
> > > > Thanks again Steve, I appreciate your patience with me ... Greg
> > > > 
> > > > "Steve Rindsberg" wrote:
> > > > 
> > > > > Give this a try instead:
> > > > > 
> > > > > First, you need to add this to the event class if it's not already there:
> > > > > 
> > > > > Private Sub PPTEvent_SlideShowNextSlide(ByVal wn As SlideShowWindow)
> > > > >     Call Auto_NextSlide(wn)
> > > > > End Sub
> > > > > 
> > > > > Note that the parameter passed to the event is the slide show window, not the slide 
> > > > > index; in your code module, this:
> > > > > 
> > > > > Sub Auto_NextSlide(wn As SlideShowWindow)
> > > > > ' Note again that the slide show window is the parameter,
> > > > > ' not slide index
> > > > > 
> > > > >     ' declare this as static so its value 
> > > > >     ' is retained between invocations of the sub
> > > > >     Static LastSlide As Long
> > > > >     
> > > > >     Dim CurrentSlide As Long
> > > > >     
> > > > >     CurrentSlide = wn.View.Slide.SlideIndex
> > > > >     
> > > > >     MsgBox "Slide No: " & CurrentSlide
> > > > >     
> > > > >     If LastSlide = 0 Then
> > > > >         ' we just started the show
> > > > >         ' add special case code here or ignore
> > > > >         '
> > > > >         ' we'll ignore:
> > > > >         LastSlide = CurrentSlide
> > > > >         Exit Sub
> > > > >     End If
> > > > >     
> > > > >     If CurrentSlide > LastSlide Then
> > > > >     ' we moved forward
> > > > >         ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> > > > >         .ImportFromFile "c:\program files\microsoft office\media\laser.wav"
> > > > >     Else
> > > > >     ' we moved backward
> > > > >         ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> > > > >         .ImportFromFile "c:\program files\microsoft office\media\type.wav"
> > > > >     End If
> > > > > 
> > > > >     LastSlide = CurrentSlide
> > > > > 
> > > > > End Sub
> > > > > 
> > > > > 
> > > > > In article , Gvm wrote:
> > > > > > Steve,
> > > > > > I have based my macro on Shyam Pillai's sub that reports the index number in 
> > > > > > a message box after each slide transition. Use of the sub shows that the 
> > > > > > variable "index" reports the correct slide number transitioning both forwards 
> > > > > > and backwards. Since Nextslide runs before moving to the next slide and I 
> > > > > > read that "SlideIndex" is the index of the next slide, I thought the test for 
> > > > > > whether transition is forward or back is simply a comparison of Shyam's 
> > > > > > "index" and "SlideIndex". 
> > > > > > 
> > > > > > So what follows is my adaptation of Shyam's macro. I expect there are a 
> > > > > > number of problems in it, but the first is that the sub loops on the first 
> > > > > > slide, ie the message box pos up repeatedly and it is necessary to terminate 
> > > > > > ppt to get out of the loop. I would appreciate your help, TIA .. Greg
> > > > > > 
> > > > > > Sub Auto_NextSlide(Index As Long)
> > > > > > Dim CurrentSlide As Long
> > > > > > CurrentSlide = Index
> > > > > > MsgBox "Slide No:" & Index
> > > > > >     If ActivePresentation.SlideShowWindow.View.Slide.SlideIndex > 
> > > > > > CurrentSlide Then
> > > > > > ' we moved forward
> > > > > >     ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> > > > > >     .ImportFromFile "c:\program files\microsoft office\media\laser.wav"
> > > > > > Else
> > > > > > ' we moved backward
> > > > > >     ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> > > > > >     .ImportFromFile "c:\program files\microsoft office\media\type.wav"
> > > > > > End If
> > > > > > End Sub
> > > > > > 
> > > > > > "Steve Rindsberg" wrote:
> > > > > > 
> > > > > > > In article , Gvm wrote:
> > > > > > > > I have a certain sound play each time the ppt slide show transitions forwards 
> > > > > > > > from one slide to the following one. The same sound plays when I transition 
> > > > > > > > in reverse, ie from one slide to the previous slide. Using standard 
> > > > > > > > functions, is it possible to set different sounds when transitioning forward 
> > > > > > > > and in reverse? 
> > > > > > > 
> > > > > > > No, afraid not.
> > > > > > > 
> > > > > > > > If not, can a macro be written that runs each time there is a slide 
> > > > > > > > transition, detects whether the transition is forward or backward, and 
> > > > > > > > depending on the direction plays either one of two sounds?
> > > > > > > 
> > > > > > > Probably so. You'd need to implement an event handler in an add-in:
> > > > > > > 
> > > > > > > Make PPT respond to events
> > > > > > > http://www.pptfaq.com/FAQ00004.htm
> > > > > > > 
> > > > > > > It could trap slide changes and by storing the previous slide's Index in a 
> > > > > > > global or static variable, compare that with the current slide to work out if 
> > > > > > > you're moving forward or backward.
> > > > > > > 
> > > > > > > I'm not sure exactly when the event fires though ... on or after slide change. 
> > > > > > > That might make a difference.
> > > > > > > 
> > > > > > > 
> > > > > > > --
> > > > > > > Steve Rindsberg, PPT MVP
> > > > > > > PPT FAQ:  www.pptfaq.com
> > > > > > > PPTools:  www.pptools.com
> > > > > > > ================================================
> > > > > > > 
> > > > > > > 
> > > > > > >
> > > > > >
> > > > > 
> > > > > --
> > > > > Steve Rindsberg, PPT MVP
> > > > > PPT FAQ:  www.pptfaq.com
> > > > > PPTools:  www.pptools.com
> > > > > ================================================
> > > > > 
> > > > > 
> > > > >
> > > >
> > > 
> > > --
> > > Steve Rindsberg, PPT MVP
> > > PPT FAQ:  www.pptfaq.com
> > > PPTools:  www.pptools.com
> > > ================================================
> > > 
> > > 
> > >
> >
> 
> --
> Steve Rindsberg, PPT MVP
> PPT FAQ:  www.pptfaq.com
> PPTools:  www.pptools.com
> ================================================
> 
> 
>
date: Mon, 4 Aug 2008 20:26:00 -0700   author:   gvm

Re: forward and backward slide transitions .. programming differen   
In article , Gvm wrote:
> Thanks again Steve. re your advice "The line:
> Dim cPPTObject As New cEventClass
> assumes that you have a class named cEventClass
> Try renaming your Class1 to that."
> 
> two things:
> (1) How do I rename the Class1 module please? Obviously it is not as easy as 
> right clicking and selecting Rename on the VBAProject(test.ppt)/Class 
> Modules/Class 1 icon.

You need to have the Properties window open.  Then when you click on your class module, you'll 
see its name next to (Name).  Click in the name to the right of that to edit/change it.

> (2) Perhaps my code is incomplete because neither the statement "Dim 
> cPPTObject As New cEventClass" nor cPPTObject is apparent in my code. 

That'll keep it from working all right.  Check Shyam's Event Handler demo on this page:

http://skp.mvps.org/download.htm

I'd start with that, verify that it's working, then comment out what you don't need and add your 
own code back into it.

I have 
> pasted my code from both modules below for your inspection. Regards ... Greg
>        Stored in: VBAProject(test.ppt)/Class Modules/Class 1....
> Private Sub Class_Initialize()
> End Sub
> Private Sub PPTEvent_SlideShowNextSlide(ByVal wn As SlideShowWindow)
>     Call Auto_NextSlide(wn)
> End Sub
> 
>        And stored in VBAProject(test.ppt)/Modules/Module 1
> Sub Auto_NextSlide(wn As SlideShowWindow)
> ' Note again that the slide show window is the parameter, not slide index
>  ' declare this as static so its value is retained between invocations of 
> the sub
>     Static LastSlide As Long   
>     Dim CurrentSlide As Long    
>     CurrentSlide = wn.View.Slide.SlideIndex    
>     MsgBox "Slide No: " & CurrentSlide
>     
>     If LastSlide = 0 Then
>         ' we just started the show
>         ' add special case code here or ignore
>         '
>         ' we'll ignore:
>         LastSlide = CurrentSlide
>         Exit Sub
>     End If
>     
>     If CurrentSlide > LastSlide Then
>     ' we moved forward
>         ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
>         .ImportFromFile "c:\program files\microsoft office\media\laser.wav"
>     Else
>     ' we moved backward
>         ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
>         .ImportFromFile "c:\program files\microsoft office\media\type.wav"
>     End If
> 
>     LastSlide = CurrentSlide
> End Sub
> 
> --------  end of code -----------
> "Steve Rindsberg" wrote:
> 
> > I missed something in your earlier post ... my bad
> > 
> > The line:
> > 
> > Dim cPPTObject As New cEventClass
> > 
> > assumes that you have a class named cEventClass
> > 
> > Try renaming your Class1 to that.
> > 
> > 
> > n article , Gvm wrote:
> > > Steve, 
> > > re your question "is test.ppt the file where your macros are stored?", the 
> > > answer is I think so; - the macro is visible when I view the source code in 
> > > VBAProject(test.ppt)/Modules/Module 1.
> > > 
> > > Re your point about having to reset the event handler: I disabled and 
> > > re-enabled Auto Events inside ppt. Is that the way to reset the event trap? 
> > > Doing so appears to have failed to make any difference - tne event handler / 
> > > macro still doesn't fire.
> > > 
> > > kind regards ... Greg
> > > 
> > > "Steve Rindsberg" wrote:
> > > 
> > > > In article , Gvm wrote:
> > > > > Thanks Steve. 
> > > > > I updated the macro code you provided me in 
> > > > > VBAProject(test.ppt)/Modules/Module 1 and created and pasted the Private Sub 
> > > > > PPTEvent subroutine in VBAProject(test.ppt)/Class Modules/Class 1. 
> > > > > 
> > > > > AutoEvents is enabled within ppt but the event and/or macro is not firing. 
> > > > > Have I interpreted your instructions correctly? 
> > > > 
> > > > Possibly, but remember that within a PPT, every time you edit the macro or get an error 
> > > > message, it's likely going to disable event trapping, so you have to re-set the event 
> > > > trap.
> > > > 
> > > > > I noticed that if I select Tools/Macro/Macros from test.ppt, no macros are 
> > > > > listed as being present in test.ppt. Is this expected, or is it an indication 
> > > > > of why I have a problem?
> > > > 
> > > > Not sure ... is test.ppt the file where your macros are stored?
> > > > 
> > > > > 
> > > > > Thanks again Steve, I appreciate your patience with me ... Greg
> > > > > 
> > > > > "Steve Rindsberg" wrote:
> > > > > 
> > > > > > Give this a try instead:
> > > > > > 
> > > > > > First, you need to add this to the event class if it's not already there:
> > > > > > 
> > > > > > Private Sub PPTEvent_SlideShowNextSlide(ByVal wn As SlideShowWindow)
> > > > > >     Call Auto_NextSlide(wn)
> > > > > > End Sub
> > > > > > 
> > > > > > Note that the parameter passed to the event is the slide show window, not the slide 
> > > > > > index; in your code module, this:
> > > > > > 
> > > > > > Sub Auto_NextSlide(wn As SlideShowWindow)
> > > > > > ' Note again that the slide show window is the parameter,
> > > > > > ' not slide index
> > > > > > 
> > > > > >     ' declare this as static so its value 
> > > > > >     ' is retained between invocations of the sub
> > > > > >     Static LastSlide As Long
> > > > > >     
> > > > > >     Dim CurrentSlide As Long
> > > > > >     
> > > > > >     CurrentSlide = wn.View.Slide.SlideIndex
> > > > > >     
> > > > > >     MsgBox "Slide No: " & CurrentSlide
> > > > > >     
> > > > > >     If LastSlide = 0 Then
> > > > > >         ' we just started the show
> > > > > >         ' add special case code here or ignore
> > > > > >         '
> > > > > >         ' we'll ignore:
> > > > > >         LastSlide = CurrentSlide
> > > > > >         Exit Sub
> > > > > >     End If
> > > > > >     
> > > > > >     If CurrentSlide > LastSlide Then
> > > > > >     ' we moved forward
> > > > > >         ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> > > > > >         .ImportFromFile "c:\program files\microsoft office\media\laser.wav"
> > > > > >     Else
> > > > > >     ' we moved backward
> > > > > >         ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> > > > > >         .ImportFromFile "c:\program files\microsoft office\media\type.wav"
> > > > > >     End If
> > > > > > 
> > > > > >     LastSlide = CurrentSlide
> > > > > > 
> > > > > > End Sub
> > > > > > 
> > > > > > 
> > > > > > In article , Gvm wrote:
> > > > > > > Steve,
> > > > > > > I have based my macro on Shyam Pillai's sub that reports the index number in 
> > > > > > > a message box after each slide transition. Use of the sub shows that the 
> > > > > > > variable "index" reports the correct slide number transitioning both forwards 
> > > > > > > and backwards. Since Nextslide runs before moving to the next slide and I 
> > > > > > > read that "SlideIndex" is the index of the next slide, I thought the test for 
> > > > > > > whether transition is forward or back is simply a comparison of Shyam's 
> > > > > > > "index" and "SlideIndex". 
> > > > > > > 
> > > > > > > So what follows is my adaptation of Shyam's macro. I expect there are a 
> > > > > > > number of problems in it, but the first is that the sub loops on the first 
> > > > > > > slide, ie the message box pos up repeatedly and it is necessary to terminate 
> > > > > > > ppt to get out of the loop. I would appreciate your help, TIA .. Greg
> > > > > > > 
> > > > > > > Sub Auto_NextSlide(Index As Long)
> > > > > > > Dim CurrentSlide As Long
> > > > > > > CurrentSlide = Index
> > > > > > > MsgBox "Slide No:" & Index
> > > > > > >     If ActivePresentation.SlideShowWindow.View.Slide.SlideIndex > 
> > > > > > > CurrentSlide Then
> > > > > > > ' we moved forward
> > > > > > >     ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> > > > > > >     .ImportFromFile "c:\program files\microsoft office\media\laser.wav"
> > > > > > > Else
> > > > > > > ' we moved backward
> > > > > > >     ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> > > > > > >     .ImportFromFile "c:\program files\microsoft office\media\type.wav"
> > > > > > > End If
> > > > > > > End Sub
> > > > > > > 
> > > > > > > "Steve Rindsberg" wrote:
> > > > > > > 
> > > > > > > > In article , Gvm wrote:
> > > > > > > > > I have a certain sound play each time the ppt slide show transitions forwards 
> > > > > > > > > from one slide to the following one. The same sound plays when I transition 
> > > > > > > > > in reverse, ie from one slide to the previous slide. Using standard 
> > > > > > > > > functions, is it possible to set different sounds when transitioning forward 
> > > > > > > > > and in reverse? 
> > > > > > > > 
> > > > > > > > No, afraid not.
> > > > > > > > 
> > > > > > > > > If not, can a macro be written that runs each time there is a slide 
> > > > > > > > > transition, detects whether the transition is forward or backward, and 
> > > > > > > > > depending on the direction plays either one of two sounds?
> > > > > > > > 
> > > > > > > > Probably so. You'd need to implement an event handler in an add-in:
> > > > > > > > 
> > > > > > > > Make PPT respond to events
> > > > > > > > http://www.pptfaq.com/FAQ00004.htm
> > > > > > > > 
> > > > > > > > It could trap slide changes and by storing the previous slide's Index in a 
> > > > > > > > global or static variable, compare that with the current slide to work out if 
> > > > > > > > you're moving forward or backward.
> > > > > > > > 
> > > > > > > > I'm not sure exactly when the event fires though ... on or after slide change. 
> > > > > > > > That might make a difference.
> > > > > > > > 
> > > > > > > > 
> > > > > > > > --
> > > > > > > > Steve Rindsberg, PPT MVP
> > > > > > > > PPT FAQ:  www.pptfaq.com
> > > > > > > > PPTools:  www.pptools.com
> > > > > > > > ================================================
> > > > > > > > 
> > > > > > > > 
> > > > > > > >
> > > > > > >
> > > > > > 
> > > > > > --
> > > > > > Steve Rindsberg, PPT MVP
> > > > > > PPT FAQ:  www.pptfaq.com
> > > > > > PPTools:  www.pptools.com
> > > > > > ================================================
> > > > > > 
> > > > > > 
> > > > > >
> > > > >
> > > > 
> > > > --
> > > > Steve Rindsberg, PPT MVP
> > > > PPT FAQ:  www.pptfaq.com
> > > > PPTools:  www.pptools.com
> > > > ================================================
> > > > 
> > > > 
> > > >
> > >
> > 
> > --
> > Steve Rindsberg, PPT MVP
> > PPT FAQ:  www.pptfaq.com
> > PPTools:  www.pptools.com
> > ================================================
> > 
> > 
> >
>

--
Steve Rindsberg, PPT MVP
PPT FAQ:  www.pptfaq.com
PPTools:  www.pptools.com
================================================
date: Tue, 05 Aug 2008 10:48:40 EDT   author:   Steve Rindsberg

Re: forward and backward slide transitions .. programming differen   
Dear Steve,
the job is nearly done, thanks so much for your help. The problem now is the 
commands intended to create the soundeffects are wrong. Can you suggest the 
correct way to set and play the sounds please?

Also, does the event handler have to be started and ended manually using the 
button on Shyam's slide? Or can this manual procedure be substituted by 
simply enabling and disabling the event handler on the tools/auto events drop 
down menu?  

This is so exciting for me. I have confirmed the only remaining problem is 
the playing of the sound effect because I have watched the macro step to the 
appropriate sound effect command depending on whether the transition is 
forward or reverse. Hooray!

TIA ... Greg

"Steve Rindsberg" wrote:

> In article , Gvm wrote:
> > Thanks again Steve. re your advice "The line:
> > Dim cPPTObject As New cEventClass
> > assumes that you have a class named cEventClass
> > Try renaming your Class1 to that."
> > 
> > two things:
> > (1) How do I rename the Class1 module please? Obviously it is not as easy as 
> > right clicking and selecting Rename on the VBAProject(test.ppt)/Class 
> > Modules/Class 1 icon.
> 
> You need to have the Properties window open.  Then when you click on your class module, you'll 
> see its name next to (Name).  Click in the name to the right of that to edit/change it.
> 
> > (2) Perhaps my code is incomplete because neither the statement "Dim 
> > cPPTObject As New cEventClass" nor cPPTObject is apparent in my code. 
> 
> That'll keep it from working all right.  Check Shyam's Event Handler demo on this page:
> 
> http://skp.mvps.org/download.htm
> 
> I'd start with that, verify that it's working, then comment out what you don't need and add your 
> own code back into it.
> 
> I have 
> > pasted my code from both modules below for your inspection. Regards ... Greg
> >        Stored in: VBAProject(test.ppt)/Class Modules/Class 1....
> > Private Sub Class_Initialize()
> > End Sub
> > Private Sub PPTEvent_SlideShowNextSlide(ByVal wn As SlideShowWindow)
> >     Call Auto_NextSlide(wn)
> > End Sub
> > 
> >        And stored in VBAProject(test.ppt)/Modules/Module 1
> > Sub Auto_NextSlide(wn As SlideShowWindow)
> > ' Note again that the slide show window is the parameter, not slide index
> >  ' declare this as static so its value is retained between invocations of 
> > the sub
> >     Static LastSlide As Long   
> >     Dim CurrentSlide As Long    
> >     CurrentSlide = wn.View.Slide.SlideIndex    
> >     MsgBox "Slide No: " & CurrentSlide
> >     
> >     If LastSlide = 0 Then
> >         ' we just started the show
> >         ' add special case code here or ignore
> >         '
> >         ' we'll ignore:
> >         LastSlide = CurrentSlide
> >         Exit Sub
> >     End If
> >     
> >     If CurrentSlide > LastSlide Then
> >     ' we moved forward
> >         ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> >         .ImportFromFile "c:\program files\microsoft office\media\laser.wav"
> >     Else
> >     ' we moved backward
> >         ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> >         .ImportFromFile "c:\program files\microsoft office\media\type.wav"
> >     End If
> > 
> >     LastSlide = CurrentSlide
> > End Sub
> > 
> > --------  end of code -----------
> > "Steve Rindsberg" wrote:
> > 
> > > I missed something in your earlier post ... my bad
> > > 
> > > The line:
> > > 
> > > Dim cPPTObject As New cEventClass
> > > 
> > > assumes that you have a class named cEventClass
> > > 
> > > Try renaming your Class1 to that.
> > > 
> > > 
> > > n article , Gvm wrote:
> > > > Steve, 
> > > > re your question "is test.ppt the file where your macros are stored?", the 
> > > > answer is I think so; - the macro is visible when I view the source code in 
> > > > VBAProject(test.ppt)/Modules/Module 1.
> > > > 
> > > > Re your point about having to reset the event handler: I disabled and 
> > > > re-enabled Auto Events inside ppt. Is that the way to reset the event trap? 
> > > > Doing so appears to have failed to make any difference - tne event handler / 
> > > > macro still doesn't fire.
> > > > 
> > > > kind regards ... Greg
> > > > 
> > > > "Steve Rindsberg" wrote:
> > > > 
> > > > > In article , Gvm wrote:
> > > > > > Thanks Steve. 
> > > > > > I updated the macro code you provided me in 
> > > > > > VBAProject(test.ppt)/Modules/Module 1 and created and pasted the Private Sub 
> > > > > > PPTEvent subroutine in VBAProject(test.ppt)/Class Modules/Class 1. 
> > > > > > 
> > > > > > AutoEvents is enabled within ppt but the event and/or macro is not firing. 
> > > > > > Have I interpreted your instructions correctly? 
> > > > > 
> > > > > Possibly, but remember that within a PPT, every time you edit the macro or get an error 
> > > > > message, it's likely going to disable event trapping, so you have to re-set the event 
> > > > > trap.
> > > > > 
> > > > > > I noticed that if I select Tools/Macro/Macros from test.ppt, no macros are 
> > > > > > listed as being present in test.ppt. Is this expected, or is it an indication 
> > > > > > of why I have a problem?
> > > > > 
> > > > > Not sure ... is test.ppt the file where your macros are stored?
> > > > > 
> > > > > > 
> > > > > > Thanks again Steve, I appreciate your patience with me ... Greg
> > > > > > 
> > > > > > "Steve Rindsberg" wrote:
> > > > > > 
> > > > > > > Give this a try instead:
> > > > > > > 
> > > > > > > First, you need to add this to the event class if it's not already there:
> > > > > > > 
> > > > > > > Private Sub PPTEvent_SlideShowNextSlide(ByVal wn As SlideShowWindow)
> > > > > > >     Call Auto_NextSlide(wn)
> > > > > > > End Sub
> > > > > > > 
> > > > > > > Note that the parameter passed to the event is the slide show window, not the slide 
> > > > > > > index; in your code module, this:
> > > > > > > 
> > > > > > > Sub Auto_NextSlide(wn As SlideShowWindow)
> > > > > > > ' Note again that the slide show window is the parameter,
> > > > > > > ' not slide index
> > > > > > > 
> > > > > > >     ' declare this as static so its value 
> > > > > > >     ' is retained between invocations of the sub
> > > > > > >     Static LastSlide As Long
> > > > > > >     
> > > > > > >     Dim CurrentSlide As Long
> > > > > > >     
> > > > > > >     CurrentSlide = wn.View.Slide.SlideIndex
> > > > > > >     
> > > > > > >     MsgBox "Slide No: " & CurrentSlide
> > > > > > >     
> > > > > > >     If LastSlide = 0 Then
> > > > > > >         ' we just started the show
> > > > > > >         ' add special case code here or ignore
> > > > > > >         '
> > > > > > >         ' we'll ignore:
> > > > > > >         LastSlide = CurrentSlide
> > > > > > >         Exit Sub
> > > > > > >     End If
> > > > > > >     
> > > > > > >     If CurrentSlide > LastSlide Then
> > > > > > >     ' we moved forward
> > > > > > >         ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> > > > > > >         .ImportFromFile "c:\program files\microsoft office\media\laser.wav"
> > > > > > >     Else
> > > > > > >     ' we moved backward
> > > > > > >         ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> > > > > > >         .ImportFromFile "c:\program files\microsoft office\media\type.wav"
> > > > > > >     End If
> > > > > > > 
> > > > > > >     LastSlide = CurrentSlide
> > > > > > > 
> > > > > > > End Sub
> > > > > > > 
> > > > > > > 
> > > > > > > In article , Gvm wrote:
> > > > > > > > Steve,
> > > > > > > > I have based my macro on Shyam Pillai's sub that reports the index number in 
> > > > > > > > a message box after each slide transition. Use of the sub shows that the 
> > > > > > > > variable "index" reports the correct slide number transitioning both forwards 
> > > > > > > > and backwards. Since Nextslide runs before moving to the next slide and I 
> > > > > > > > read that "SlideIndex" is the index of the next slide, I thought the test for 
> > > > > > > > whether transition is forward or back is simply a comparison of Shyam's 
> > > > > > > > "index" and "SlideIndex". 
> > > > > > > > 
> > > > > > > > So what follows is my adaptation of Shyam's macro. I expect there are a 
> > > > > > > > number of problems in it, but the first is that the sub loops on the first 
> > > > > > > > slide, ie the message box pos up repeatedly and it is necessary to terminate 
> > > > > > > > ppt to get out of the loop. I would appreciate your help, TIA .. Greg
> > > > > > > > 
> > > > > > > > Sub Auto_NextSlide(Index As Long)
> > > > > > > > Dim CurrentSlide As Long
> > > > > > > > CurrentSlide = Index
> > > > > > > > MsgBox "Slide No:" & Index
> > > > > > > >     If ActivePresentation.SlideShowWindow.View.Slide.SlideIndex > 
> > > > > > > > CurrentSlide Then
> > > > > > > > ' we moved forward
> > > > > > > >     ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> > > > > > > >     .ImportFromFile "c:\program files\microsoft office\media\laser.wav"
> > > > > > > > Else
> > > > > > > > ' we moved backward
> > > > > > > >     ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> > > > > > > >     .ImportFromFile "c:\program files\microsoft office\media\type.wav"
> > > > > > > > End If
> > > > > > > > End Sub
> > > > > > > > 
> > > > > > > > "Steve Rindsberg" wrote:
> > > > > > > > 
> > > > > > > > > In article , Gvm wrote:
> > > > > > > > > > I have a certain sound play each time the ppt slide show transitions forwards 
> > > > > > > > > > from one slide to the following one. The same sound plays when I transition 
> > > > > > > > > > in reverse, ie from one slide to the previous slide. Using standard 
> > > > > > > > > > functions, is it possible to set different sounds when transitioning forward 
> > > > > > > > > > and in reverse? 
> > > > > > > > > 
> > > > > > > > > No, afraid not.
> > > > > > > > > 
> > > > > > > > > > If not, can a macro be written that runs each time there is a slide 
> > > > > > > > > > transition, detects whether the transition is forward or backward, and 
> > > > > > > > > > depending on the direction plays either one of two sounds?
> > > > > > > > > 
> > > > > > > > > Probably so. You'd need to implement an event handler in an add-in:
> > > > > > > > > 
> > > > > > > > > Make PPT respond to events
> > > > > > > > > http://www.pptfaq.com/FAQ00004.htm
> > > > > > > > > 
> > > > > > > > > It could trap slide changes and by storing the previous slide's Index in a 
> > > > > > > > > global or static variable, compare that with the current slide to work out if 
> > > > > > > > > you're moving forward or backward.
> > > > > > > > > 
> > > > > > > > > I'm not sure exactly when the event fires though ... on or after slide change. 
> > > > > > > > > That might make a difference.
> > > > > > > > > 
> > > > > > > > > 
> > > > > > > > > --
> > > > > > > > > Steve Rindsberg, PPT MVP
> > > > > > > > > PPT FAQ:  www.pptfaq.com
> > > > > > > > > PPTools:  www.pptools.com
> > > > > > > > > ================================================
> > > > > > > > > 
> > > > > > > > > 
> > > > > > > > >
> > > > > > > >
> > > > > > > 
> > > > > > > --
> > > > > > > Steve Rindsberg, PPT MVP
> > > > > > > PPT FAQ:  www.pptfaq.com
> > > > > > > PPTools:  www.pptools.com
> > > > > > > ================================================
> > > > > > > 
> > > > > > > 
> > > > > > >
> > > > > >
> > > > > 
> > > > > --
> > > > > Steve Rindsberg, PPT MVP
> > > > > PPT FAQ:  www.pptfaq.com
> > > > > PPTools:  www.pptools.com
> > > > > ================================================
> > > > > 
> > > > > 
> > > > >
> > > >
> > > 
> > > --
> > > Steve Rindsberg, PPT MVP
> > > PPT FAQ:  www.pptfaq.com
> > > PPTools:  www.pptools.com
> > > ================================================
> > > 
> > > 
> > >
> >
> 
> --
> Steve Rindsberg, PPT MVP
> PPT FAQ:  www.pptfaq.com
> PPTools:  www.pptools.com
> ================================================
> 
> 
>
date: Wed, 6 Aug 2008 17:12:00 -0700   author:   gvm

Re: forward and backward slide transitions .. programming differen   
In article , Gvm wrote:
> Dear Steve,
> the job is nearly done, thanks so much for your help. The problem now is the 
> commands intended to create the soundeffects are wrong. Can you suggest the 
> correct way to set and play the sounds please?

Too sleepy to answer that one coherently ... hang in there. ;-)

> Also, does the event handler have to be started and ended manually using the 
> button on Shyam's slide? Or can this manual procedure be substituted by 
> simply enabling and disabling the event handler on the tools/auto events drop 
> down menu?  

Generally, the event handler would be initialized in the Auto_Open subroutine in an add0-in 

Tools/AutoEvents dropdown menu ..?  Where's THAT bad boy?  ;-)



> 
> This is so exciting for me. I have confirmed the only remaining problem is 
> the playing of the sound effect because I have watched the macro step to the 
> appropriate sound effect command depending on whether the transition is 
> forward or reverse. Hooray!
> 
> TIA ... Greg
> 
> "Steve Rindsberg" wrote:
> 
> > In article , Gvm wrote:
> > > Thanks again Steve. re your advice "The line:
> > > Dim cPPTObject As New cEventClass
> > > assumes that you have a class named cEventClass
> > > Try renaming your Class1 to that."
> > > 
> > > two things:
> > > (1) How do I rename the Class1 module please? Obviously it is not as easy as 
> > > right clicking and selecting Rename on the VBAProject(test.ppt)/Class 
> > > Modules/Class 1 icon.
> > 
> > You need to have the Properties window open.  Then when you click on your class module, you'll 
> > see its name next to (Name).  Click in the name to the right of that to edit/change it.
> > 
> > > (2) Perhaps my code is incomplete because neither the statement "Dim 
> > > cPPTObject As New cEventClass" nor cPPTObject is apparent in my code. 
> > 
> > That'll keep it from working all right.  Check Shyam's Event Handler demo on this page:
> > 
> > http://skp.mvps.org/download.htm
> > 
> > I'd start with that, verify that it's working, then comment out what you don't need and add your 
> > own code back into it.
> > 
> > I have 
> > > pasted my code from both modules below for your inspection. Regards ... Greg
> > >        Stored in: VBAProject(test.ppt)/Class Modules/Class 1....
> > > Private Sub Class_Initialize()
> > > End Sub
> > > Private Sub PPTEvent_SlideShowNextSlide(ByVal wn As SlideShowWindow)
> > >     Call Auto_NextSlide(wn)
> > > End Sub
> > > 
> > >        And stored in VBAProject(test.ppt)/Modules/Module 1
> > > Sub Auto_NextSlide(wn As SlideShowWindow)
> > > ' Note again that the slide show window is the parameter, not slide index
> > >  ' declare this as static so its value is retained between invocations of 
> > > the sub
> > >     Static LastSlide As Long   
> > >     Dim CurrentSlide As Long    
> > >     CurrentSlide = wn.View.Slide.SlideIndex    
> > >     MsgBox "Slide No: " & CurrentSlide
> > >     
> > >     If LastSlide = 0 Then
> > >         ' we just started the show
> > >         ' add special case code here or ignore
> > >         '
> > >         ' we'll ignore:
> > >         LastSlide = CurrentSlide
> > >         Exit Sub
> > >     End If
> > >     
> > >     If CurrentSlide > LastSlide Then
> > >     ' we moved forward
> > >         ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> > >         .ImportFromFile "c:\program files\microsoft office\media\laser.wav"
> > >     Else
> > >     ' we moved backward
> > >         ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> > >         .ImportFromFile "c:\program files\microsoft office\media\type.wav"
> > >     End If
> > > 
> > >     LastSlide = CurrentSlide
> > > End Sub
> > > 
> > > --------  end of code -----------
> > > "Steve Rindsberg" wrote:
> > > 
> > > > I missed something in your earlier post ... my bad
> > > > 
> > > > The line:
> > > > 
> > > > Dim cPPTObject As New cEventClass
> > > > 
> > > > assumes that you have a class named cEventClass
> > > > 
> > > > Try renaming your Class1 to that.
> > > > 
> > > > 
> > > > n article , Gvm wrote:
> > > > > Steve, 
> > > > > re your question "is test.ppt the file where your macros are stored?", the 
> > > > > answer is I think so; - the macro is visible when I view the source code in 
> > > > > VBAProject(test.ppt)/Modules/Module 1.
> > > > > 
> > > > > Re your point about having to reset the event handler: I disabled and 
> > > > > re-enabled Auto Events inside ppt. Is that the way to reset the event trap? 
> > > > > Doing so appears to have failed to make any difference - tne event handler / 
> > > > > macro still doesn't fire.
> > > > > 
> > > > > kind regards ... Greg
> > > > > 
> > > > > "Steve Rindsberg" wrote:
> > > > > 
> > > > > > In article , Gvm wrote:
> > > > > > > Thanks Steve. 
> > > > > > > I updated the macro code you provided me in 
> > > > > > > VBAProject(test.ppt)/Modules/Module 1 and created and pasted the Private Sub 
> > > > > > > PPTEvent subroutine in VBAProject(test.ppt)/Class Modules/Class 1. 
> > > > > > > 
> > > > > > > AutoEvents is enabled within ppt but the event and/or macro is not firing. 
> > > > > > > Have I interpreted your instructions correctly? 
> > > > > > 
> > > > > > Possibly, but remember that within a PPT, every time you edit the macro or get an error 
> > > > > > message, it's likely going to disable event trapping, so you have to re-set the event 
> > > > > > trap.
> > > > > > 
> > > > > > > I noticed that if I select Tools/Macro/Macros from test.ppt, no macros are 
> > > > > > > listed as being present in test.ppt. Is this expected, or is it an indication 
> > > > > > > of why I have a problem?
> > > > > > 
> > > > > > Not sure ... is test.ppt the file where your macros are stored?
> > > > > > 
> > > > > > > 
> > > > > > > Thanks again Steve, I appreciate your patience with me ... Greg
> > > > > > > 
> > > > > > > "Steve Rindsberg" wrote:
> > > > > > > 
> > > > > > > > Give this a try instead:
> > > > > > > > 
> > > > > > > > First, you need to add this to the event class if it's not already there:
> > > > > > > > 
> > > > > > > > Private Sub PPTEvent_SlideShowNextSlide(ByVal wn As SlideShowWindow)
> > > > > > > >     Call Auto_NextSlide(wn)
> > > > > > > > End Sub
> > > > > > > > 
> > > > > > > > Note that the parameter passed to the event is the slide show window, not the slide 
> > > > > > > > index; in your code module, this:
> > > > > > > > 
> > > > > > > > Sub Auto_NextSlide(wn As SlideShowWindow)
> > > > > > > > ' Note again that the slide show window is the parameter,
> > > > > > > > ' not slide index
> > > > > > > > 
> > > > > > > >     ' declare this as static so its value 
> > > > > > > >     ' is retained between invocations of the sub
> > > > > > > >     Static LastSlide As Long
> > > > > > > >     
> > > > > > > >     Dim CurrentSlide As Long
> > > > > > > >     
> > > > > > > >     CurrentSlide = wn.View.Slide.SlideIndex
> > > > > > > >     
> > > > > > > >     MsgBox "Slide No: " & CurrentSlide
> > > > > > > >     
> > > > > > > >     If LastSlide = 0 Then
> > > > > > > >         ' we just started the show
> > > > > > > >         ' add special case code here or ignore
> > > > > > > >         '
> > > > > > > >         ' we'll ignore:
> > > > > > > >         LastSlide = CurrentSlide
> > > > > > > >         Exit Sub
> > > > > > > >     End If
> > > > > > > >     
> > > > > > > >     If CurrentSlide > LastSlide Then
> > > > > > > >     ' we moved forward
> > > > > > > >         ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> > > > > > > >         .ImportFromFile "c:\program files\microsoft office\media\laser.wav"
> > > > > > > >     Else
> > > > > > > >     ' we moved backward
> > > > > > > >         ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> > > > > > > >         .ImportFromFile "c:\program files\microsoft office\media\type.wav"
> > > > > > > >     End If
> > > > > > > > 
> > > > > > > >     LastSlide = CurrentSlide
> > > > > > > > 
> > > > > > > > End Sub
> > > > > > > > 
> > > > > > > > 
> > > > > > > > In article , Gvm wrote:
> > > > > > > > > Steve,
> > > > > > > > > I have based my macro on Shyam Pillai's sub that reports the index number in 
> > > > > > > > > a message box after each slide transition. Use of the sub shows that the 
> > > > > > > > > variable "index" reports the correct slide number transitioning both forwards 
> > > > > > > > > and backwards. Since Nextslide runs before moving to the next slide and I 
> > > > > > > > > read that "SlideIndex" is the index of the next slide, I thought the test for 
> > > > > > > > > whether transition is forward or back is simply a comparison of Shyam's 
> > > > > > > > > "index" and "SlideIndex". 
> > > > > > > > > 
> > > > > > > > > So what follows is my adaptation of Shyam's macro. I expect there are a 
> > > > > > > > > number of problems in it, but the first is that the sub loops on the first 
> > > > > > > > > slide, ie the message box pos up repeatedly and it is necessary to terminate 
> > > > > > > > > ppt to get out of the loop. I would appreciate your help, TIA .. Greg
> > > > > > > > > 
> > > > > > > > > Sub Auto_NextSlide(Index As Long)
> > > > > > > > > Dim CurrentSlide As Long
> > > > > > > > > CurrentSlide = Index
> > > > > > > > > MsgBox "Slide No:" & Index
> > > > > > > > >     If ActivePresentation.SlideShowWindow.View.Slide.SlideIndex > 
> > > > > > > > > CurrentSlide Then
> > > > > > > > > ' we moved forward
> > > > > > > > >     ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> > > > > > > > >     .ImportFromFile "c:\program files\microsoft office\media\laser.wav"
> > > > > > > > > Else
> > > > > > > > > ' we moved backward
> > > > > > > > >     ActivePresentation.Slides(1).SlideShowTransition.SoundEffect _
> > > > > > > > >     .ImportFromFile "c:\program files\microsoft office\media\type.wav"
> > > > > > > > > End If
> > > > > > > > > End Sub
> > > > > > > > > 
> > > > > > > > > "Steve Rindsberg" wrote:
> > > > > > > > > 
> > > > > > > > > > In article , Gvm wrote:
> > > > > > > > > > > I have a certain sound play each time the ppt slide show transitions forwards 
> > > > > > > > > > > from one slide to the following one. The same sound plays when I transition 
> > > > > > > > > > > in reverse, ie from one slide to the previous slide. Using standard 
> > > > > > > > > > > functions, is it possible to set different sounds when transitioning forward 
> > > > > > > > > > > and in reverse? 
> > > > > > > > > > 
> > > > > > > > > > No, afraid not.
> > > > > > > > > > 
> > > > > > > > > > > If not, can a macro be written that runs each time there is a slide 
> > > > > > > > > > > transition, detects whether the transition is forward or backward, and 
> > > > > > > > > > > depending on the direction plays either one of two sounds?
> > > > > > > > > > 
> > > > > > > > > > Probably so. You'd need to implement an event handler in an add-in:
> > > > > > > > > > 
> > > > > > > > > > Make PPT respond to events
> > > > > > > > > > http://www.pptfaq.com/FAQ00004.htm
> > > > > > > > > > 
> > > > > > > > > > It could trap slide changes and by storing the previous slide's Index in a 
> > > > > > > > > > global or static variable, compare that with the current slide to work out if 
> > > > > > > > > > you're moving forward or backward.
> > > > > > > > > > 
> > > > > > > > > > I'm not sure exactly when the event fires though ... on or after slide change. 
> > > > > > > > > > That might make a difference.
> > > > > > > > > > 
> > > > > > > > > > 
> > > > > > > > > > --
> > > > > > > > > > Steve Rindsberg, PPT MVP
> > > > > > >