2015-04-23 55 views
0

日安执行,简报VBA:从第2个幻灯片

我有这个代码来修改所有幻灯片上的各种形状的大小和位置,但想的程序只从幻灯片开始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} 

我需要改变什么?

回答

0

检查幻灯片的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 
0

欧莱的正确。或者另一种方法,我改变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