我在Excel中创建了一个旋转3D图表的宏.我将图表复制到PowerPoint中,设置代码以在幻灯片显示时在PowerPoint中运行.代码运行,但我无法让它实际更改屏幕上显示的内容.幻灯片处于编辑模式时,图形会旋转.知道如何让代码不仅仅运行(我可以看到调试数字显示),但在演示模式下更新屏幕?我的代码是:
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
Run Code Online (Sandbox Code Playgroud)
更新:我还在打这个.似乎有些建议说更新当前显示的图表,您需要在DoEvents下面使用:
SlideShowWindows(1).View.GotoSlide SlideSowWindows(1).View.CurrentShowPosition
Run Code Online (Sandbox Code Playgroud)
但这不起作用.它退出正在运行的任何代码.因此,第一个函数中的Do/Loop退出,并且不会继续进行第二次迭代.