簡體   English   中英

在PowerPoint演示文稿中旋轉3D圖表

[英]Spinning 3D chart in PowerPoint presentation

我在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

更新:我還在打這個。 似乎有些建議說更新當前顯示的圖表,您需要在DoEvents下面使用:

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

但這不起作用。 它退出正在運行的任何代碼。 因此,第一個函數中的Do / Loop退出,並且不會繼續進行第二次迭代。

如果圖表在編輯模式下旋轉,為什么不將它作為.GIF記錄在演示文稿中?

將動畫GIF添加到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演示期間,您熟悉宏的其他問題嗎? 它們在這樣的環境中非常脆弱,必須仔細測試它們的效果。

OnSlideShowPageChange只有在之前激活VBA時才有效。 最簡單的方法是在開始演示之前打開和關閉VBA編輯器。

問候

阿克塞爾

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM