Export multiple grouped objects / shapes to files at once

ollyhughes1982

Well-known Member
Joined
Nov 27, 2018
Messages
795
Office Version
  1. 365
Platform
  1. MacOS
Hi all,

I have a file with quite a lot of grouped objects in, and I'd like to be able to export these to a folder. is there some VBA or something that i can use to do this?

I have many of them (hundreds) and don't want to right-click and Save As Picture for all of them, if I can at all help it!

I'd also like to do this from a Word file - would it be the same?

I'm on a Mac.

Thanks in advance,

Olly.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
I don't have a Mac version of Office, but you should be able to save your document as a "Web Page", which would export all images (pictures, shapes, charts, etc) to a folder all at once. Here's an example, using Excel. The same thing can be done in Word.


Hope this helps!
 
Upvote 0
I don't have a Mac version of Office, but you should be able to save your document as a "Web Page", which would export all images (pictures, shapes, charts, etc) to a folder all at once. Here's an example, using Excel. The same thing can be done in Word.


Hope this helps!
Ah yes, I tried that method thanks, but it ungroups all the grouped shapes / objects into their component parts. I need the grouped shapes / objects to remain grouped.
 
Upvote 0
I found this (VBA, below) on another Microsoft forum, but it is for PowerPoint. I wonder if someone could adapt this for Excel / Word on the Mac. My VBA skills are limited, at best:

VBA Code:
Sub ExportShapesAsPNGs()    Dim sld As Slide    Dim shp As Shape    Dim path As String    Dim name As String    Dim i As Integer    path = "C:\Users\Username\Desktop\"    For Each sld In ActivePresentation.Slides        For Each shp In sld.Shapes            If shp.Type <> msoPlaceholder Then                i = i + 1                name = shp.Name & ".png"                shp.Export path & name, ppShapeFormatPNG            End If        Next shp    Next sld    MsgBox i & " shapes exported as PNGs."End Sub

This was found here: How do I export multiple objects and groups as individual PNGs all at once in PPT? - Microsoft Q&A

Thanks.
 
Upvote 0
That's interesting, when I save the workbook as a Web Page, it exports the grouped shapes as one image, in addition to separate images. In any case, since no one with a Mac version of Excel has posted a solution, see if this helps...

VBA Code:
Sub ExportShapesAsPNGs()
    
    Dim ws As Worksheet
    Dim chrtObj As ChartObject
    Dim shp As Shape
    Dim path As String
    Dim name As String
    Dim i As Integer

    path = "C:\Users\Username\Desktop\"

    For Each ws In ActiveWorkbook.Worksheets
        For Each shp In ws.Shapes
            i = i + 1
            name = shp.name & ".png"
            shp.CopyPicture xlScreen, xlPicture
            Set chrtObj = ws.ChartObjects.Add(Left:=0, Top:=0, Width:=shp.Width, Height:=shp.Height)
            With chrtObj
                .Activate
                With .Chart
                    .ChartArea.Format.Line.Visible = msoFalse
                    .Paste
                    .Export Filename:=path & name
                End With
                .Delete
            End With
        Next shp
    Next ws
    
    MsgBox i & " shapes exported as PNGs."
    
End Sub

Hope this helps!
 
Upvote 0
That's interesting, when I save the workbook as a Web Page, it exports the grouped shapes as one image, in addition to separate images. In any case, since no one with a Mac version of Excel has posted a solution, see if this helps...

VBA Code:
Sub ExportShapesAsPNGs()
  
    Dim ws As Worksheet
    Dim chrtObj As ChartObject
    Dim shp As Shape
    Dim path As String
    Dim name As String
    Dim i As Integer

    path = "C:\Users\Username\Desktop\"

    For Each ws In ActiveWorkbook.Worksheets
        For Each shp In ws.Shapes
            i = i + 1
            name = shp.name & ".png"
            shp.CopyPicture xlScreen, xlPicture
            Set chrtObj = ws.ChartObjects.Add(Left:=0, Top:=0, Width:=shp.Width, Height:=shp.Height)
            With chrtObj
                .Activate
                With .Chart
                    .ChartArea.Format.Line.Visible = msoFalse
                    .Paste
                    .Export Filename:=path & name
                End With
                .Delete
            End With
        Next shp
    Next ws
  
    MsgBox i & " shapes exported as PNGs."
  
End Sub

Hope this helps!
Thanks, I’Il give it a try tomorrow, but I’m thinking that the filepath bit likely won’t work on a Mac, as they’re different?
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,157
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top