Hey guys I am writing a macro for PowerPoint at work that when the first slide plays it sets a Custom Document Property, which is used in a C# environment later to test if the slide show has been viewed or not. Here is the code I am using:
[vba]Sub OnSlideShowPageChange()
'If ssw.View.CurrentShowPosition = ssw.Presentation.SlideShowSettings.StartingSlide Then
If ActivePresentation.CustomDocumentProperties.Count > 0 Then
ActivePresentation.CustomDocumentProperties("point2").Delete
End If
Dim i As Integer
i = ActivePresentation.SlideShowWindow.View.CurrentShowPosition
If i <> 1 Then Exit Sub
ActivePresentation.CustomDocumentProperties.Add Name:="point2", LinkToContent:=False, Type:=msoPropertyTypeString, Value:="True"
End Sub[/vba]Note: I commented out the first line in the sub as I think that is a better way to test the first slide, but sense I can't get this working with the code that was provided on this site I'm not using it yet until I resolve this problem.

Here is the problem, If I go into the Developer tab and click Visual Basic to view/edit the code and then click Play the show this works fine; but if the code has not been viewed then the code does not run at all. What am I missing here guys? I don't see how there is a difference in code execution as to whether or not the editor is opened. This code is currently inside its own Module, I have also tried a Class Module but that didn't work even with the code editor open.

So with further tinkering I have found that I can also get this code to run if I click Macros and select Run for OnSlideShowPageChange, which will give me an error because there is no active slide show, and on running the slide show the macro works fine. Why would this only work after the code has been viewed or I manually attempt to execute it?

I also read on here that OnSlideShowPageChange can be quirky and it might be necessary to call it manually. but when I added the line
[vba]Call OnSlideShowPageChange[/vba] No code runs even where it did before and I am given an error "Invalid outside procedure". I am currently looking into this further but any advice would be fantastic. I understand this error is because the call is not inside a sub of its own, but then I have to call THAT sub from another Sub to call OnSlideShowPageChange which defeats the whole point of calling the sub OnSlideShowPageChange.