When ungrouping shapes in a PowerPoint presentation, it is important taking into account, that this will affect the number of shapes available on a slide. It is thus advised to ungroup the shapes first, and then iterate over the new shapes collection like so:
$pp = New-Object -comobject PowerPoint.Application
$pp.visible = [Microsoft.Office.Core.MsoTriState]::msoTrue
$pres = $pp.Presentations.Open("C:\Presentation.ppt")
Foreach( $slide in $pres.Slides ) {
Foreach( $shape in $slide.Shapes ) {
If( $shape.Type -eq [Microsoft.Office.Core.MsoShapeType]::msoGroup ) {
$shape.Ungroup()
}
}
Foreach( $shape in $slide.Shapes ) {
.
.
.
}
}
$pp.Quit()
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($pp)
Remove-Variable pp
[gc]::collect()
[gc]::WaitForPendingFinalizers()
dlvrt
Leave a comment