Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spinning 3D chart in PowerPoint presentation

I created a macro in Excel that will spin a 3D chart. I copied the chart into PowerPoint, set up the code to run in PowerPoint when the slide is shown. The code runs, but I cannot get it to actually change what is shown on the screen. When the slide is in edit mode, the graph rotates. Any idea how to get the code to not just run (I can see the debug numbers showing up), but update the screen when in Presentation Mode? My code is:

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Public Sub SpinTheChart()

    RotateX = ActivePresentation.Slides(2).Shapes(2).Chart.ChartArea.Format _
                    .ThreeD.RotationX

    Do While ActivePresentation.SlideShowWindow.View.CurrentShowPosition = 2
        RotateX = RotateX + 7
        If RotateX > 360 Then RotateX = RotateX - 360
        ActivePresentation.Slides(2).Shapes(2).Chart.ChartArea.Format _
                    .ThreeD.RotationX = RotateX
        DoEvents
        Sleep 125
        Debug.Print RotateX
    Loop

End Sub

Sub OnSlideShowPageChange()
    Dim i As Integer
    i = ActivePresentation.SlideShowWindow.View.CurrentShowPosition
    If i = 2 Then SpinTheChart
End Sub

UPDATE: I am still fighting this. It seems some recomendations say to update the currently displayed chart, you need to use, below the DoEvents:

SlideShowWindows(1).View.GotoSlide SlideSowWindows(1).View.CurrentShowPosition

but this does not work. It exits any code that is running. So the Do/Loop in the first function is exited and it does not go on to the second iteration.

like image 207
Dan Hendrickson Avatar asked Oct 22 '13 15:10

Dan Hendrickson


1 Answers

If the chart spins in Edit mode, why don't you record it as a .GIF an include that in the presentation?

Add an animated GIF to PowerPoint: https://support.office.com/en-us/article/Add-an-animated-GIF-to-a-slide-3a04f755-25a9-42c4-8cc1-1da4148aef01

Recording your screen: http://www.screentogif.com

like image 51
Neil Mussett Avatar answered Oct 03 '22 17:10

Neil Mussett