0

I have a picture on sheet 'Picture' A1 that i want to save as a PNG file, and the name is located in Q2.

Once saved i want to delete the picture also.

This is as far as i can get, but in my macro it never captures the saving process. Any suggestions

Sub save()
'
' save Macro
'

'
    range("Q2").Select
    Selection.Copy
    ActiveSheet.Shapes.range(Array("Picture 57")).Select
    Selection.Delete
End Sub

Thanksenter image description here

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
MT1000
  • 21
  • 5
  • You can't save a picture as PNG. Therefore you need to copy it into a chart object and export that. See [How to save group of shapes as JPG image?](https://stackoverflow.com/questions/60304480/how-to-save-group-of-shapes-as-jpg-image) and [Save Shape As A PNG File](https://www.thespreadsheetguru.com/blog/vba-save-as-picture-file-excel#yui_3_17_2_1_1613396265078_593). – Pᴇʜ Feb 15 '21 at 13:40
  • You might benefit from reading [How to avoid using Select in Excel VBA](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba). – Pᴇʜ Feb 15 '21 at 13:41
  • Thanks for this, i will look into it. I have just attached a snippet of a manual save to PNG, are you suggesting that this cant be done using VBA, only manually? – MT1000 Feb 15 '21 at 13:47
  • Yes, a picture is a `Shape` Object and this has no method to save a picture (see [Shape object (Excel) - Methods](https://learn.microsoft.com/en-us/office/vba/api/excel.shape#methods)) but you can copy a `Shape` into a `Chart` object which as an `Export` and `ExportAsFixedFormat` method (see [Chart object (Excel) - Methods](https://learn.microsoft.com/en-us/office/vba/api/excel.chart(object)#methods)) and this way is a workaround to export the shape within a chart. – Pᴇʜ Feb 15 '21 at 13:53

0 Answers0