Hi dude,
you need to turn the image into a background image of a chart and then export the chart as a picture - .jpg .bmp .gif
I had the same problem and managed to sort it. I had a work book with fifty sheets and wanted to export the picture from each sheet and save it as a filename that was also on that sheet.
Here is the code i used, feel free to modify it for your purposes.
Public Sub Export()
Dim objTemp As Object
Dim objHolder As ChartObject
Dim sngWidth As Integer
Dim sngHeight As Integer
Dim TheFilename
On Error GoTo skip
TheFilename = Cells(3, 11).Value
'sets the picture as a temp object
Set objTemp = ActiveSheet.Shapes(2)
ActiveSheet.Shapes(2).Select
Selection.ShapeRange.ScaleHeight 1#, msoTrue, msoScaleFromTopLeft
Selection.ShapeRange.ScaleWidth 1#, msoTrue, msoScaleFromTopLeft
sngWidth = objTemp.Width
sngHeight = objTemp.Height
Charts.Add
ActiveChart.Location Where:=xlLocationAsObject, Name:=SheetNo
Set objHolder = ThisWorkbook.Worksheets("Sheet1").ChartObjects(1)
With objHolder
.Width = sngWidth + 20
.Height = sngHeight + 20
objTemp.Copy
End With
With objHolder
.Chart.Paste
With .Chart.Shapes(1)
.Placement = xlMove
.Left = -4
.Top = -4
End With
.Width = sngWidth
.Height = sngHeight
.Chart.Export Filename:="C:\Photos\" & TheFilename & ".jpg", FilterName:="JPG"
.Chart.Shapes(1).Delete
End With
skip:
End Sub
|