So I have a fairly complex PowerPoint I've been working on--it is a complex training program combined with a testing portion that presents multiple choice questions some of which are just text, some of which are graphical, some of which are animated graphics, and some of which are synthesized speech and audio, etc. When the user answers a slide incorrectly, VBA code copies the slide to the end of the presentation so that the user must answer missed questions again to ensure learning the correct response.
Anyway, I had added about 200 slides and then I ran into a problem. After running a certain slide, the VBA code that copied the slide started causing an error of "invalid function" for the simple line of code: oSld.Copy. I then tried manually copying the slide by using CTRL+C in the slide editing window and I got a similar error but worded differently; something like this: "We're sorry, something went wrong that might make PowerPoint unstable. Please save your presentation and restart PowerPoint."
I was completely baffled by this odd behavior and thought perhaps the PowerPoint was balking at the number of slides, so, I reduced the number of slides to only 15 or so, but, the same slide still caused problems at oSld.Copy and CTRL+C.
I spent hours trying to narrow down where the error was occurring and it seemed consistently linked to this one slide for the longest time. But then, I happened to get the same error on another slide. The commonality was that they both had unusual animations on the slides. Specifically, on both slides, I had a group of shapes and the group was animated with the "Lines" animation that moved the group of shapes from one point to another point.
When I deleted the animations from those slides, there was no longer an error for oSld.Copy nor when using CTRL+C.
My workaround (which to this point in time has worked) was that I added code to delete the animations from the source slide after copying the source slide to the end of the presentation. Fortunately, the error with the copying seems only to occur when trying to copy a second slide with a complex animation, not after copying the first slide with a complex animation. Thus, by deleting the complex animation after copying the slide, the animation was correctly copied to the slide at the end of the presentation, but apparently deleting the animation from the source slide prevented problems when copying the next complex animation slide.
I modified code by John Wilson of PowerPoint Alchemy to delete the animations as follows:
Sub DeleteAnimations()
Dim i As Integer
Dim t As Integer
Dim osld As Slide
'delete anims from just the current slide
Set osld = ActivePresentation.Slides(ActivePresentation.SlideShowWindow.View.CurrentShowPosition)
'Remove normal animations
For i = osld.TimeLine.MainSequence.Count To 1 Step -1
osld.TimeLine.MainSequence(i).Delete
Next i
'Remove triggers
For i = osld.TimeLine.InteractiveSequences.Count To 1 Step -1
For t = osld.TimeLine.InteractiveSequences(i).Count To 1 Step -1
osld.TimeLine.InteractiveSequences(i).Item(t).Delete
Next t
Next i
End Sub
I was pulling my hair out trying to get rid of the error and since it took me so long to figure it out, I hope that posting this information here will help out some other individual.