Spinning 3D Graphics in a PowerPoint Presentation

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.

+7
vba excel-vba excel powerpoint-vba powerpoint
source share
2 answers

If the chart rotates in edit mode, why don't you write it as .GIF and include it in the presentation?

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

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

+1
source share

Changes in the charts do not seem to trigger the SlideShowView update. But changes in the text in the figures will do it. Thus, the following code rotates the chart:

 Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Public Sub SpinTheChart() Set oSlide = ActivePresentation.Slides("Slide1") Set oChart = oSlide.Shapes("Diagramm 4").Chart oChart.ChartArea.Format.ThreeD.RotationX = 20 snRotationX = oChart.ChartArea.Format.ThreeD.RotationX Do While ActivePresentation.SlideShowWindow.View.Slide.Name = "Slide1" snRotationX = snRotationX + 7 If snRotationX > 360 Then snRotationX = snRotationX - 360 oChart.ChartArea.Format.ThreeD.RotationX = snRotationX 'oSlide.Shapes("Rechteck 7").TextFrame.TextRange.Text = snRotationX oSlide.Shapes.Title.TextFrame.TextRange.Text = oSlide.Shapes.Title.TextFrame.TextRange.Text DoEvents Sleep 125 Loop End Sub Sub OnSlideShowPageChange(ByVal SSW As SlideShowWindow) If SSW.View.Slide.Name = "Slide1" _ Then SpinTheChart End Sub 

Are you familiar with other macro issues during a PowerPoint presentation? They are very fragile in such an environment, and their effects must be carefully checked.

And OnSlideShowPageChange only works if VBA has been activated before. The easiest way is to open and close the VBA editor before starting the presentation.

Hi

Axel

0
source share

All Articles