Skip to content

Instantly share code, notes, and snippets.

@DevPicon
Last active February 18, 2016 16:33
Show Gist options
  • Save DevPicon/aae61e0ab3a445984c98 to your computer and use it in GitHub Desktop.
Save DevPicon/aae61e0ab3a445984c98 to your computer and use it in GitHub Desktop.
Code to apply some customizations to Powepoint objects
Sub configure_animations()
Dim oshp As Shape
Dim osld As Slide
Set oshp = ActiveWindow.Selection.ShapeRange(1)
Set osld = Application.ActiveWindow.View.Slide
' Add entering effect to shape oshp
osld.TimeLine.MainSequence.AddEffect oshp, msoAnimEffectFade, , msoAnimTriggerOnPageClick
' Apply the same effect but set Exiting flag on TRUE
Dim effMain As Effect
Set effMain = osld.TimeLine.MainSequence.AddEffect(oshp, msoAnimEffectFade, , msoAnimTriggerOnPageClick)
effMain.Exit = msoTrue
End Sub
Sub configure_square()
Dim oshp As Shape
Set oshp = ActiveWindow.Selection.ShapeRange(1)
' Validate if the object is a shape
If oshp.Type = msoAutoShape Then
oshp.Line.Weight = 1.5
oshp.Line.Style = msoLineSingle
oshp.Line.ForeColor.RGB = RGB(57, 197, 231)
' Activate transparency
oshp.Fill.Transparency = 1
End If
End Sub
Sub massive_resize()
Dim oshp As Shape
Set oshp = ActiveWindow.Selection.ShapeRange(1)
' Validate if the object is a picture
If oshp.Type = msoPicture Then
oshp.LockAspectRatio = msoTrue
' We have to convert each centimeter in points (1 cm = 28.34 pts)
oshp.Width = 22.8 * 28.34
' Center image in slide
oshp.Left = ActivePresentation.PageSetup.SlideWidth / 2 - oshp.Width / 2
oshp.Top = ActivePresentation.PageSetup.SlideHeight / 2 - oshp.Height / 2
oshp.Line.Weight = 1.5
oshp.Line.Style = msoLineSingle
oshp.Line.ForeColor.RGB = RGB(57, 197, 231)
End If
End Sub
@DevPicon
Copy link
Author

This code let me apply a format to selected image into a slide

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment