I created a macro in Excel that will rotate a three-dimensional chart. I copied the chart in PowerPoint, set up the code to run in PowerPoint when the slide is displayed. The code works, but I can't 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 make the code not just run (I see that debug numbers appear), but refresh the screen 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 struggling with this. Some recommendations seem to say update the chart currently being displayed, which you should use under DoEvents:
SlideShowWindows(1).View.GotoSlide SlideSowWindows(1).View.CurrentShowPosition
but it does not work. It exits from any executable code. Thus, the Do / Loop in the first function ends, and it does not go to the second iteration.
vba excel-vba excel powerpoint-vba powerpoint
Dan hendrickson
source share