2015-04-23 3 views
0

Добрый день,Powerpoint 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 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 

Dim х As Long

'For Each osld In ActivePresentation.Slides 

При х = 2 до ActivePresentation.Slides.Count

Set 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 
Смежные вопросы