VBA未将整个图表复制到PowerPoint中
我正在处理一个问题,在复制到powerpoint幻灯片时,我的VBA代码以某种方式选择不包含整个图表。我有以下代码: 这段代码从2个数字创建我的甜甜圈图表VBA未将整个图表复制到PowerPoint中,vba,excel,powerpoint,excel-charts,Vba,Excel,Powerpoint,Excel Charts,我正在处理一个问题,在复制到powerpoint幻灯片时,我的VBA代码以某种方式选择不包含整个图表。我有以下代码: 这段代码从2个数字创建我的甜甜圈图表 Function CreateTwoValuesPie(ByVal X As Long, ByVal Y As Long) As Chart 'Returnerer Set CreateTwoValuesPie = charts.Add CreateTwoValuesPie.ChartType = XlChartType.xlDoug
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
此代码存储不同的对象和编号:
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
代码工作正常,并根据数字(d11,10-d11)创建正确的图表,但当我复制图形并将其插入powerpoint幻灯片oPPTShape10时,它仅复制图表的一部分
这可以在下图中看到:正确的答案应该与下图中的一样:
几天前就成功了,从那以后我什么都没变?有人知道我如何让它显示整个图形,而不是只显示左上角吗?它对我来说很好:)它对我也很好,没有问题。如果生成的图表在Excel中看起来很好,请尝试…(1)。(2) 生成一个全新的空白pptx文件(不使用任何公司模板),至少添加一张幻灯片,并使用此幻灯片插入图表(这样我们可以确保PowerPoint模板没有任何问题)。尝试手动执行相同的操作。图表是否仍然被截断?对于某些用户来说,这似乎是重复发生的。他们中的一些人报告说,更改Windows DPI设置解决了这个问题(IIRC,他们在具有非常高rez显示的系统上)