1

I'm trying to export a single image to a folder.

I inserted the image manually in the workbook, and renamed the shape 'logo'.

I've used something similar earlier, but perhaps it only works with OLEObjects?

ThisWorkbook.Sheets("Start Here").Shapes("logo").Copy
CreateObject("Shell.Application").Namespace(ThisWorkbook.Path & "\").Self.InvokeVerb "Paste"

The code runs, but the object isn't 'pasted' to the destination directory.

Community
  • 1
  • 1
Sudio
  • 153
  • 1
  • 9

1 Answers1

1
Sub test()
Dim chtObj As ChartObject

    With ThisWorkbook.Worksheets("Start Here")

        .Activate

        Set chtObj = .ChartObjects.Add(100, 30, 400, 250)
        chtObj.Name = "TemporaryPictureChart"

        'resize chart to picture size
        chtObj.Width = .Shapes("logo").Width
        chtObj.Height = .Shapes("logo").Height

        ActiveSheet.Shapes.Range(Array("logo")).Select
        Selection.Copy

        ActiveSheet.ChartObjects("TemporaryPictureChart").Activate
        ActiveChart.Paste

        ActiveChart.Export Filename:=ThisWorkbook.Path & "\image.jpg", FilterName:="jpg"

        chtObj.Delete

    End With

End Sub

Updated code from Export Pictures Excel VBA

qz_99
  • 185
  • 1
  • 12