5

Really not sure what stack site to place this on. Feel free to move it to the correct one. My question isn't really related to programming, but I have a ton of power points with these "Worksheet Objects" embedded in the slides. Some appear to be graphs from excel as well as other chart type items from Visio. I need to convert all these "Worksheet Objects" to just images within the slide.

My process right now is copy the object > Paste as Image > Move to the correct location > Delete the "Worksheet Object". It's a very time consuming and tedious process. Is there a macro I can write or something that can convert all these objects automatically? I tried googling and no luck so far

Tom K.
  • 1,020
  • 1
  • 12
  • 28
Ronnie
  • 11,138
  • 21
  • 78
  • 140

2 Answers2

12

This should get you started:

Sub ConvertAllShapesToPic()
    Dim oSl As Slide
    Dim oSh As Shape

    For Each oSl In ActivePresentation.Slides
        For Each oSh In oSl.Shapes
            ' modify the following depending on what you want to
            ' convert
            Select Case oSh.Type
                Case msoChart, msoEmbeddedOLEObject, msoLinkedOLEObject
                    ConvertShapeToPic oSh
                Case msoPlaceholder
                    If oSh.PlaceholderFormat.ContainedType = msoEmbeddedOLEObject _
                        Or oSh.PlaceholderFormat.ContainedType = msoLinkedOLEObject _
                        Or oSh.PlaceholderFormat.ContainedType = msoChart _
                        Then
                        ConvertShapeToPic oSh
                    End If
                Case Else

            End Select
        Next
    Next

End Sub

Sub ConvertShapeToPic(ByRef oSh As Shape)
    Dim oNewSh As Shape
    Dim oSl As Slide

    Set oSl = oSh.Parent
    oSh.Copy
    Set oNewSh = oSl.Shapes.PasteSpecial(ppPasteEnhancedMetafile)(1)

    With oNewSh
        .Left = oSh.Left
        .Top = oSh.Top
        Do
            .ZOrder (msoSendBackward)
        Loop Until .ZOrderPosition < oSh.ZOrderPosition
    End With

    oSh.Delete

End Sub
Steve Rindsberg
  • 14,442
  • 1
  • 29
  • 34
  • Steve, kudos to you man, this is great. I've never played with VB or even macros, but I figured it out within a few minutes. The code snippet worked great. This will surely save me a ton of time – Ronnie Oct 26 '12 at 16:17
  • Glad it helped. One other thing I forgot to mention earlier ... this version gives you EMFs (which can be ungrouped and edited). If you don't want them editable, you might want to change that parameter to have it paste PNGs instead. – Steve Rindsberg Oct 27 '12 at 17:20
  • Note that this won't work for worksheet objects and charts contained in placeholders, which is where you would normally expect them to appear. Also, the Do loop should check the ZOrderPosition of the new shape against a variable containing the original ZOrderPosition of the original shape. – OfficeAddinDev Dec 28 '18 at 14:47
  • @OfficeAddinDev Thanks for both catches. I've modified the code accordingly. – Steve Rindsberg Dec 29 '18 at 19:25
1

Other quick alternative if you do not want to write a macro is to cut the object (Ctrl + x) and then paste it (Ctrl + v) as img (we can use paste special to select the image format or when we do a paste (Ctrl + v) MS power point will prompt with options to paste then select image in it). This way we need not have to save the image to a location on drive and then insert it back in the slide. Cut and Paste will work while being on the same slide.

Santosh Sindham
  • 879
  • 8
  • 18
  • That is what I use to do, but with a long power point with many objects, macro is the way to go – Ronnie Apr 04 '16 at 19:40