3

I'm dealing with an issue where my VBA code somehow chooses not to include the whole chart when copying to a powerpoint slide. I have the following code:

This code creates my Doughnut chart from 2 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 store the different object 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 figure and insert it into my powerpoint slide oPPTShape10 it only copy part of the chart.

This can be seen in the image below:
Image1

The correct should've look like the one in the image below:
Image2

It worked some days ago and I haven't changed anything since then? Does anyone know how I can make it show the whole figure instead of only the topleft corner of it?

user108176
  • 39
  • 1
  • 1
  • 5
  • 1
    It works just fine for me :) – Siddharth Rout Jun 06 '17 at 08:34
  • 1
    It works for me too, no issues. Try … (1) if your generated chart looks fine in Excel. (2) Generate a completely new blank pptx file (not using any company templates), add at least one slide and use this for inserting the chart (so we can ensure it isn't any issue with the PowerPoint template). – Pᴇʜ Jun 06 '17 at 09:31
  • 1
    Try performing the same operation manually. Does the chart still get cut off? This does seem to happen repeatably for some users. A couple of them have reported that changing the Windows DPI setting solved the problem (IIRC, they were on systems with very high rez displays) – Steve Rindsberg Jun 06 '17 at 14:29

0 Answers0