如何在powerpoint中添加排除最后一张幻灯片的进度条

时间:2016-06-29 09:03:22

标签: powerpoint-vba

基本上我想在我的powerpoint中添加一个不包含整个演示文稿的进度条。但是我有一些额外的幻灯片,我可能不需要在演示时,因此想要从进度条中排除。

Sub AddProgressBar()
    On Error Resume Next
        With ActivePresentation
              sHeight = .PageSetup.SlideHeight - 12
              n = 0
              j = 0
              For i = 1 To .Slides.Count
                If .Slides(i).SlideShowTransition.Hidden Then j = j + 1
              Next i:
              For i = 2 To .Slides.Count
                .Slides(i).Shapes("progressBar").Delete
                If .Slides(i).SlideShowTransition.Hidden = msoFalse Then
                  Set slider = .Slides(i).Shapes.AddShape(msoShapeRectangle, 0, sHeight, (i - n) * .PageSetup.SlideWidth / (.Slides.Count - j), 12)
                  With slider
                      .Fill.ForeColor.RGB = ActivePresentation.SlideMaster.ColorScheme.Colors(ppFill).RGB
                      .Name = "progressBar"
                  End With
                Else
                   n = n + 1
                End If
              Next i:
        End With
End Sub

Sub RemoveProgressBar()
    On Error Resume Next
        With ActivePresentation
              For i = 22 To .Slides.Count
              .Slides(i).Shapes("progressBar").Delete
              .Slides(i).Shapes("pageNumber").Delete
              Next i:
        End With
End Sub

这是我到目前为止所做的,但它显示了包含进度条的“最终”幻灯片中未完成的进度条。

1 个答案:

答案 0 :(得分:0)

将.Slides.Count替换为您希望显示进度条的最后一张幻灯片的索引。您可以使用InputBox输入值来使其动态化。