Last active
May 20, 2024 04:55
-
-
Save JimMoyle/4cdf2d7fca960ccecc17f797957ce3f7 to your computer and use it in GitHub Desktop.
Copy randomize and paste animations in Powerpoint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$shapeName = 'Rounded Rectangle 664' | |
Add-type -AssemblyName office | |
$Application = New-Object -ComObject powerpoint.application | |
$application.visible = [Microsoft.Office.Core.MsoTriState]::msoTrue | |
$powerpointFile = "D:\PoSHCode\GitLocal\PowerPoint\RandomLogoff3.pptx" | |
$presentation = $application.Presentations.open($powerpointFile) | |
$slide = $presentation.Slides[1] | |
$one = $slide.Shapes | Where-Object { $_.Name -eq $shapeName } | |
$one.PickupAnimation() | |
$ids = $slide.shapes | Where-Object { $_.Name -ne $shapeName -and $_.AutoShapeType -eq 5 } | Select-Object -ExpandProperty 'Id' | |
while ($ids.count -gt 0) { | |
$randomId = $ids | get-random | |
$shape = $slide.Shapes | Where-Object { $_.Id -eq $randomId } | |
$shape.ApplyAnimation() | |
$ids = $ids | Where-Object { $_ -ne $randomId } | |
} | |
$presentation.Save() | |
$presentation.Close() | |
$application.quit() | |
$application = $null | |
[gc]::collect() | |
[gc]::WaitForPendingFinalizers() | |
Write-Output 'Done' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment