我在Excel中創建了一個可以旋轉3D圖表的宏。我將圖表複製到PowerPoint中,將代碼設置爲在幻燈片顯示時在PowerPoint中運行。代碼運行,但我無法實際改變屏幕上顯示的內容。幻燈片處於編輯模式時,圖形將旋轉。任何想法如何讓代碼不只是運行(我可以看到調試數字顯示),但更新屏幕時,在演示模式?我的代碼是:在PowerPoint演示文稿中旋轉3D圖表
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
更新: 我還在爲此而戰。這似乎有些recomendations說來更新當前顯示的圖表,你需要使用時,下面的DoEvents:
SlideShowWindows(1).View.GotoSlide SlideSowWindows(1).View.CurrentShowPosition
但這不起作用。它退出正在運行的任何代碼。所以第一個函數中的Do/Loop被退出,並且不會繼續執行第二次迭代。
你檢查,以確保對象使用Excel和PowerPoint中的相同的接口? –
是您的更新:從代碼中精確複製代碼?如果是這樣,請檢查下半部分的拼寫,其中'SlideShowWindows'拼寫錯誤。 –
四個月前你問過這個問題,但沒有答案:你有沒有解決過這個問題? –