Skip to content

Instantly share code, notes, and snippets.

@ivikash
Created February 7, 2025 06:27
Show Gist options
  • Save ivikash/eae2c18b2a292421ddb0d5febd2663e9 to your computer and use it in GitHub Desktop.
Save ivikash/eae2c18b2a292421ddb0d5febd2663e9 to your computer and use it in GitHub Desktop.
Align All Videos in a PPT presentation
Sub AlignVideos()
Dim slideIndex As Integer
Dim shape As shape
Dim referenceTop As Single
Dim referenceLeft As Single
Dim referenceHeight As Single
Dim referenceWidth As Single
Dim firstVideoFound As Boolean
firstVideoFound = False
' Loop through slides
For slideIndex = 1 To ActivePresentation.Slides.Count
For Each shape In ActivePresentation.Slides(slideIndex).Shapes
' Check if the shape is a media object (video)
If shape.Type = msoMedia Then
' If it's the first video, set it as the reference
If Not firstVideoFound Then
referenceTop = shape.Top
referenceLeft = shape.Left
referenceHeight = shape.Height
referenceWidth = shape.Width
firstVideoFound = True
Else
' Align other videos to the first one
shape.Top = referenceTop
shape.Left = referenceLeft
shape.Height = referenceHeight
shape.Width = referenceWidth
End If
End If
Next shape
Next slideIndex
MsgBox "All videos aligned successfully!", vbInformation, "Alignment Complete"
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment