run macro every time Slide show is shown

BobSullivan
3StarLounger
Posts: 235
Joined: 08 Jun 2010, 20:03
Location: Morgantown, PA

run macro every time Slide show is shown

Post by BobSullivan »

I have another question that is haunting me today. Same presentation as yesterday. One slide, 12 combo boxes, 2 spin buttons, 5 text boxes on one slide. It's a game slide.

Internet documentation states that I can use this macro to set defaults or run code when my PowerPoint slide show starts:

Code: Select all

Sub OnSlideShowPageChange()
    Dim i As Integer
     i = ActivePresentation.SlideShowWindow.View.CurrentShowPosition
    If i <> 1 Then Exit Sub
	 'code goes here
    Next i
End Sub
But it doesn't. When I escape from the presentation, and then run the slideshow from the beginning (F5 or button), no values are reset. In fact when I set a breakpoint in the code, the macro doesn't stop, which tell me that the macro isn't even running when F5 is selected. So how can I cause code to run, to reset all the items in the slide to default values, every time?
You do not have the required permissions to view the files attached to this post.
Cordially,

Bob Sullivan
Elverson, PA

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: run macro every time Slide show is shown

Post by HansV »

OnSlideShowPageChange is just a macro; it won't run automatically.

PowerPoint VBA is weird - very weird. Unlike Word, Excel and Access, it has no built-in way to run code automatically when the presentation is opened. You need an add-in for this. You can create it yourself, or use the free add-in AutoEvents Add-in for PowerPoint 2000 and later by MVP Shyam Pillai.
Best wishes,
Hans

BobSullivan
3StarLounger
Posts: 235
Joined: 08 Jun 2010, 20:03
Location: Morgantown, PA

Re: run macro every time Slide show is shown

Post by BobSullivan »

Again, Thanks, The add in makes it work every time. :clapping:
Cordially,

Bob Sullivan
Elverson, PA