在PowerPoint演示文稿中旋转3D图表

我在Excel中创build了一个可以旋转3D图表的macros。 我将图表复制到PowerPoint中,设置代码以在幻灯片显示时在PowerPoint中运行。 代码运行,但我不能得到它实际上改变屏幕上显示的内容。 幻灯片处于编辑模式时,graphics旋转。 任何想法如何让代码不只是运行(我可以看到debugging数字显示),但更新屏幕时,在演示模式? 我的代码是:

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 

更新:我仍然在战斗。 看起来有些build议是说要更新当前显示的图表,您需要在DoEvents下面使用:

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

但是这不起作用。 它退出正在运行的任何代码。 所以第一个函数中的Do / Loop被退出,并且不会进行第二次迭代。

如果图表在“编辑”模式下旋转,为什么不把它logging为.GIF并将其包含在演示文稿中?

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

录制您的屏幕: http : //www.screentogif.com

似乎图表上的更改不会触发SlideShowView刷新。 但是在形状上的文字的变化将做到这一点。 所以下面的代码旋转图表:

 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 

在PowerPoint演示文稿中,您熟悉macros的其他问题吗? 他们在这样的环境中非常脆弱,他们的影响必须仔细testing。

而且,OnSlideShowPageChange只有在VBA之前被激活时才起作用。 最简单的方法是在开始演示之前打开和closuresVBA编辑器。

问候

阿克塞尔