VBA/Excel/Access/Word/PowerPoint/Slide Shape

Материал из VB Эксперт
Перейти к: навигация, поиск

add a bent-up arrow to the upper-right corner of the penultimate slide in the active presentation:

   <source lang="vb">

Sub bendUp()

   ActivePresentation.Slides(ActivePresentation.Slides.Count 1) _
       .Shapes.AddShape Type:=msoShapeBentUpArrow, Left:=575, Top:=10, _
       Width:=150, Height:=75

End Sub

</source>
   
  


Copying Formatting from One Shape to Another

   <source lang="vb">

Sub active()

   With ActivePresentation
       .Slides(2).Shapes(1).PickUp
       .Slides(4).Shapes(3).Apply
   End With

End Sub

</source>
   
  


Deleting a Shape

   <source lang="vb">

Sub del()

   ActivePresentation.Slides(2).Shapes(1).Delete

End Sub

</source>
   
  


Finding Out Whether a Shape Has a Text Frame

   <source lang="vb">

Sub shape()

   If ActivePresentation.Slides(1).Shapes(1).HasTextFrame = msoTrue Then
       MsgBox "The shape contains a text frame."
   End If

End Sub

</source>
   
  


Repositioning and Resizing a Shape

   <source lang="vb">

Sub pos()

   With ActivePresentation.Slides(1).Shapes(1)
       .Left = 200
       .Top = 100
       .Width = 300
       .Height = 200
   End With

End Sub

</source>
   
  


Selecting All Shapes

   <source lang="vb">

Sub select()

   ActivePresentation.Slides(myPresentation.Slides.Count).Shapes.SelectAll

End Sub

</source>
   
  


Setting an Animation for a Shape or a Range of Shapes

   <source lang="vb">

"Applies a custom animation to the first shape on the slide. Sub setting()

   With ActiveSlide.Shapes(1).AnimationSettings
       .EntryEffect = ppEffectFlyFromRight
       .AdvanceMode = ppAdvanceOnClick
       .SoundEffect.ImportFromFile FileName:="D:\Whistle.wav"
       .TextLevelEffect = ppAnimateByFirstLevel
       .TextUnitEffect = ppAnimateByParagraph
   End With

End Sub

</source>
   
  


Works with the first shape on the third slide of the presentation, moving it 100 points to the left and 200 points down, and rotating it 90 degrees counterclockwise:

   <source lang="vb">

Sub shape()

   With ActivePresentation.Slides(3).Shapes(1)
       .IncrementLeft Increment:=-100
       .IncrementTop Increment:=200
       .IncrementRotation Increment:=-90
   End With

End Sub

</source>