2015-04-23 29 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