Visual Basic Script in PowerPoint not running after file close and reopen

Hello,

I have configured the following Visual Basic module script in my PowerPoint Presentation.  As long as I create a new presentation and write the module, and do not exit from the PowerPoint program, the module will run properly every time I view the show.

However, if I exit from the presentation (after saving), and reopen it, the VB script will no longer execute.  No error messages are given -- the script simply does not run.

If you have any ideas or suggestions, or need further information from me, please do not hesitate to ask.

This is MS PowerPoint 2003 (11.8324.8329) SP3.
Sub OnSlideShowPageChange(ByVal SSW As SlideShowWindow)
    Select Case SSW.View.CurrentShowPosition
        Case 1 'slide 1
        Case 2 'slide 2
            Shell "cmd.exe /c " & Chr$(34) & "notepad" & Chr$(34), vbMinimizedFocus
        Case 3 'slide 3
    End Select
End Sub

Open in new window

Thanks for your assistance!
GenlLeeCSA1Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
JSRWilsonConnect With a Mentor Commented:
Made some minor changes. Main problem is the tagging code. It needs to be RUN from a normal module. See attached


Notepad-Test.ppt
Start-Notepad.ppt
0
 
GenlLeeCSA1Author Commented:
Thanks, JSRWilson.

Unfortunately, even after following those instructions, in addition to those here, I'm still experiencing the same symptom.

The file I'm using is attached.

Thanks,
- Adam
Video-Test.ppt
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
GenlLeeCSA1Author Commented:
The problem being that everything performs as expected when the code is first written, but no longer works at all once PowerPoint has been closed, and the file re-opened.
0
 
JSRWilsonCommented:
As I think my article details Auto_Open will NOT fire when a normal presentation is opened it needs to be in a ppa or ppam AddIn. alternatively you need a button to click to run it when the presentation first shows.
0
 
GenlLeeCSA1Author Commented:
Thanks for the clarification.

The complication is that I will need different things to execute on different slide numbers from one presentation to another.

Is there a way to have the .ppa file auto-detect which presentation is open (if / elseif statement or the like), and then fire the desired commands at the desired slide numbers based on the results of that detection?
0
 
JSRWilsonConnect With a Mentor Commented:
I would add tags to the slides

ActiveWindow.Selection.ShapeRange(1).Tags.Add "FIRE", "ACTION1" (change the second value as required)

Then have the Add In detect this:
Private Sub PPTEvent_SlideShowNextSlide(ByVal Wn As SlideShowWindow)
Dim osld As Slide
Set osld = Wn.View.Slide
If osld.Tags("FIRE") = "ACTION1" Then ....
End Sub

Open in new window

0
 
JSRWilsonCommented:
Sorry ShapeRange should be SlideRange!
0
 
GenlLeeCSA1Author Commented:
Thanks, JSRWilson.  Where do I add the tag to the slide?  Do I use a class module in the Visual Basic Editor for the presentation, or is there another procedure?

Here is the (non-functional) code I have in place as things stand.  The goal is to launch the program "notepad" when the second slide in the presentation is displayed.  The add-in is saved correctly, and loads properly when PowerPoint launches.  However, Notepad does not start.

VBA for Add-In File (Notepad Start.ppa) Module
Public cPPTObject As New cEventClass
 
Sub Auto_Open()
     'Set a application reference to the event-enabled object
    Set cPPTObject.PPTEvent = Application
End Sub

Open in new window

VBA for Add-In File (Notepad Start.ppa) Class Module "cEventClass"
Public WithEvents PPTEvent As Application
Private Sub PPTEvent_SlideShowNextSlide(ByVal Wn As SlideShowWindow)
    Dim osld As Slide
    osld = Wn.View.Slide
    If osld.Tags("FIRE") = "ACTION1" Then
        Shell "notepad"
    End If
End Sub

Open in new window

VBA for Presentation File (Notepad Test.ppt) Class Module
ActivePresentation.Slides(2).Tags.Add "FIRE", "ACTION1"

Open in new window

0
 
GenlLeeCSA1Author Commented:
The same thing occurs if "SlideRange" is used instead of "Slides" in the presentation file's class module.
0
 
GenlLeeCSA1Author Commented:
I just noted the error in line 4 of the VBA for the Add-In file.  I corrected the error, but still have no launch of the Notepad program on slide two of the Notepad Test.ppt presentation.

The code for the class module for the Notepad Start.ppa file, now unloaded and re-loaded with the corrections, now reads:

Public WithEvents PPTEvent As Application
Private Sub PPTEvent_SlideShowNextSlide(ByVal Wn As SlideShowWindow)
    Dim osld As Slide
    Set osld = Wn.View.Slide
    If osld.Tags("FIRE") = "ACTION1" Then
        Shell "notepad"
    End If
End Sub

Open in new window


Thanks,
- Adam
0
 
JSRWilsonCommented:
And you saved the code as an addin and loaded it through AddIns >>Add new?
0
 
GenlLeeCSA1Author Commented:
Yes, that is correct.
0
 
GenlLeeCSA1Author Commented:
I'm attaching two files for your review.  I'm attaching the .ppa file as the source .ppt file so that the code can be accessed and viewed.  It is saved as a .ppa and loaded as an add-in on my system.
Start-Notepad.ppt
Notepad-Test.ppt
0
 
GenlLeeCSA1Author Commented:
It works great, JSRWilson.  Thanks so much for your efforts!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.