Question

Q: Excel 2016 16.13 080401 Mac VBA Chartobject.Chart.Paste of picture does not work

This is for Excel 2016 16.13 080401 which is why I'm posting this in Insider.

I want to save a picture of a range. (for background, it's because VBA copy/paste from Excel to Powerpoint is broken and I need to export a picture and then import it in Powerpoint)

I use this code. But the Chart.Paste does not put the picture in the chart, which is the method for exporting images from Excel.

There may be a timing issue here - if I stop the code, the picture appears in the chartobject.

Sub RangePictureVBA(rgTable As Range)
   Dim oChartObject As ChartObject, shp As Object
   On Error GoTo OnError
   #If Mac Then
      rgTable.Copy ' .CopyPicture not working in Mac
      Set shp = rgTable.Worksheet.Pictures.Paste ' .DrawingObjects.paste errors, .Shapes.paste member not found
      shp.Copy
   #Else
      rgTable.CopyPicture Appearance:=xlScreen, Format:=xlPicture
   #End If
   ' add a chart this way rather than charts.add that defaults to selection or all the data on the sheet
   Set oChartObject = rgTable.Worksheet.ChartObjects.Add(Left:=rgTable.Left + rgTable.Width, Width:=rgTable.Width, Top:=rgTable.Top, Height:=rgTable.Height)
   oChartObject.Chart.Paste '<<<<<<<<<<<<<<<<<<<< This does not show the picture
   oChartObject.Chart.Export Filename:="myfile.png", filtername:="PNG"

Answer

A:

Glad to see that in Excel 16.14 build 180507, both .Copypicture and chart.paste image work.

Did this solve your problem?

Sorry this didn't help.



 
Question Info

Views: 87 Last updated: May 17, 2018 Applies to: