user5052520
user5052520

Reputation:

How to save group of shapes as JPG image?

I place a number of shapes on an image using VBA and want to save the whole group as a JPG.

Sub SaveImageTEST()
    ActiveSheet.Shapes.Range(Array("Picture 1")).SaveAsPicture "worldmap.jpg"
End Sub

The idea is to visualize data on a map:
enter image description here

Upvotes: 1

Views: 2891

Answers (1)

Loki Patera
Loki Patera

Reputation: 41

The best that I could come up with is to export as pdf, hopes this helps.

Sub SaveImage()
    'On Error Resume Next
    Set ws = ActiveSheet
    Set shp = ws.Shapes.Range(Array("Picture 1"))

    Set ch = ws.ChartObjects.Add(shp.Left, shp.Top, shp.Width, shp.Height)
    shp.Select
    Selection.Copy

    ch.Chart.Paste
    Set tt = ch.Chart

    'tt.ExportAsFixedFormat Type:=xlTypePDF, Filename:="c:\outputFileName"
    tt.Export Filename:="C:\test.png", filtername:="PNG"

    ch.Delete

End Sub

Upvotes: 1

Related Questions