【问题标题】:Powerpoint VBA: To execute from 2nd slidePowerpoint VBA:从第二张幻灯片执行
【发布时间】:2015-04-24 00:16:23
【问题描述】:

早安,

我有这个代码来修改所有幻灯片上每个形状的大小和位置,但希望该过程仅从幻灯片 2 开始。

Sub SlideLoop()
    Dim osld As Slide
    Dim oSh As Shape

    For Each osld In ActivePresentation.Slides
        ' check each shape on the slide
        ' is it an image or whatever you're looking for?
        For Each oSh In osld.Shapes
            With oSh
                If .Type = msoLinkedPicture _
                Or .Type = msoPicture Then

                ' position it to taste
                .Left = 30
                .Top = 100
                .Height = 750
                .Width = 680

                ' centering/resizing gets trickier
                ' but is still possible.
                ' Exercise for the reader?
                ' Hint:
                ' ActivePresentation.PageSetup.SlideWidth and .SlideHeight
                ' tells you the width and height of the slide
                '
                ' All values are in Points (72 to the inch)

                End If
            End With
        Next    ' Shape
    Next osld   ' Slide

End Sub}

我需要改变什么?

【问题讨论】:

    标签: vba powerpoint


    【解决方案1】:

    检查幻灯片的SlideIndex 属性 - 如果是1,则跳到下一张幻灯片。

    For Each osld In ActivePresentation.Slides 循环内,添加一个 if 语句:

    If osld.SlideIndex > 1 Then
        'Your code...
        For Each oSh In osld.Shapes
        ...
        Next    ' Shape
    End If
    

    【讨论】:

      【解决方案2】:

      Olle 是对的。或者另一种方法,我在 BOLD 中的更改:

      Sub SlideLoop()
          Dim osld As Slide
          Dim oSh As Shape
      

      将 x 变暗

      'For Each osld In ActivePresentation.Slides
      

      对于 x = 2 到 ActivePresentation.Slides.Count

      设置 oSld = ActivePresentation.Slides(x)

          ' check each shape on the slide
          ' is it an image or whatever you're looking for?
          For Each oSh In osld.Shapes
              With oSh
                  If .Type = msoLinkedPicture _
                  Or .Type = msoPicture Then
      
                  ' position it to taste
                  .Left = 30
                  .Top = 100
                  .Height = 750
                  .Width = 680
      
                  ' centering/resizing gets trickier
                  ' but is still possible.
                  ' Exercise for the reader?
                  ' Hint:
                  ' ActivePresentation.PageSetup.SlideWidth and .SlideHeight
                  ' tells you the width and height of the slide
                  '
                  ' All values are in Points (72 to the inch)
      
                  End If
              End With
          Next    ' Shape
      Next osld   ' Slide
      
      End Sub
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-04-19
        • 2012-09-15
        • 1970-01-01
        相关资源
        最近更新 更多