Powerpoint VBA: 取得當前Slide編號

主要有兩種
1.

ActiveWindow.Selection.SlideRange.SlideNumber

此處主要是在一般狀態下 (非簡報播放)
適合用來Debug

2.

SlideShowWindows(1).View.Slide.SlideIndex

此處主要是當簡報播放情況下
( 所以一般Debug模式會出錯 )

以下為實際應用

Sub Picture76_4()
    With ActivePresentation.Slides(SlideShowWindows(1).View.Slide.SlideIndex)
        If .Shapes.Title.TextFrame.TextRange.Text = "Splunk for Unix and Linux" Then
            .Shapes("Picture 4").ZOrder msoBringToFront
        End If
    End With
End Sub
Sub Picture76_5()
    With ActivePresentation.Slides(ActiveWindow.Selection.SlideRange.SlideNumber)
        MsgBox .Shapes.Title.TextFrame.TextRange.Text
        If .Shapes.Title.TextFrame.TextRange.Text = "Splunk for Unix and Linux" Then
            .Shapes("Picture 5").ZOrder msoBringToFront
        End If
    End With
End Sub
This entry was posted in Office, PowerPoint. Bookmark the permalink.