VBA/Excel/Access/Word/PowerPoint/Slide Shape — различия между версиями

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

Текущая версия на 12:46, 26 мая 2010

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

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



Copying Formatting from One Shape to Another

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



Deleting a Shape

 
Sub del()
    ActivePresentation.Slides(2).Shapes(1).Delete
End Sub



Finding Out Whether a Shape Has a Text Frame

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



Repositioning and Resizing a Shape

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



Selecting All Shapes

 
Sub select()
    ActivePresentation.Slides(myPresentation.Slides.Count).Shapes.SelectAll
End Sub



Setting an Animation for a Shape or a Range of Shapes

 
"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



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:

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