Ungrouping Items in PowerPoint with Powershell

| No Comments | No TrackBacks

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

No TrackBacks

TrackBack URL: http://blog.janus.cx/cgi-bin/mt/mt-tb.cgi/14

Leave a comment

November 2011

Sun Mon Tue Wed Thu Fri Sat
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30      

About this Entry

This page contains a single entry by Nils o. Janus published on November 16, 2011 11:05 AM.

Erste Aenderungen in der Zukunftsplanung was the previous entry in this blog.

Eindruecke der ersten Woche in Duisburg is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Categories

OpenID accepted here Learn more about OpenID