VBA does not copy the whole diagram in PowerPoint

I am dealing with an issue where my VBA code somehow chooses not to include the entire chart when copied to a PowerPoint slide. I have the following code:

This code creates my donut chart from two numbers.

Function CreateTwoValuesPie(ByVal X As Long, ByVal Y As Long) As Chart
'Returnerer
  Set CreateTwoValuesPie = charts.Add
  CreateTwoValuesPie.ChartType = XlChartType.xlDoughnut
  With CreateTwoValuesPie.SeriesCollection.NewSeries
    .Values = Array(X, Y)
  End With
  With CreateTwoValuesPie
    .ChartArea.Format.Fill.Visible = msoFalse
     .ChartArea.Format.Line.Visible = msoFalse
    .Legend.Delete
    .ChartGroups(1).DoughnutHoleSize = 70
     With .SeriesCollection(1)
        .Points(1).Format.Fill.ForeColor.RGB = RGB(255, 158, 77)   'Score Orange
        .Points(2).Format.Fill.ForeColor.RGB = RGB(175, 171, 170)  '10 - Score Grå
        .Format.Line.ForeColor.RGB = RGB(255, 255, 255)
    End With
  End With 
End Function

      

This code stores different objects and numbers:

Set oPPTApp = CreateObject("PowerPoint.Application")
Set oPPTFile = oPPTApp.Presentations.Open(PP)
Set oPPTShape10 = oPPTFile.Slides(1)
d11 = Format(Dashboard.EAScore1.Caption, "Standard")

Set ch1 = CreateTwoValuesPie(d11, 10 - d11)
ch1.CopyPicture Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture

With oPPTShape10.Shapes.Paste
    .Top = 127
    .Width = 177
    .Left = 393
End With

      

The code works fine and creates the correct chart from the number (d11, 10-d11), but when I copy the shape and paste it into the oPPTShape10 powerpoint slider, it only copies part of the chart.

This can be seen in the image below:
Image1

The correct one should look like the picture below:
Image2

It worked a few days ago and I haven't changed anything since then? Does anyone know how I can get it to show the entire shape and not just its top corner?

+3


source to share





All Articles