EXCEL vba将多个图表复制到一个powerpoint幻灯片错误“复制图表区域方法失败”

时间:2014-09-19 14:39:54

标签: excel vba powerpoint

excel多个图表分组并复制到powerpoint幻灯片问题 -

'我在ActiveChart.ChartArea.Copy中遇到问题。它给了我错误:复制chartarea的方法失败。当我尝试将它们组合在一起时,它不起作用。感谢您的帮助! - >

Public Function copy_chart2(sheet, slide)


Dim PPApp As Object
Dim PPPres As Object
Dim PPSlide As Object

Set PPApp = CreateObject("Powerpoint.Application")


Set PPApp = GetObject(, "Powerpoint.Application")
Set PPPres = PPApp.ActivePresentation
'PPApp.ActiveWindow.ViewType = ppViewSlide
PPApp.ActiveWindow.View.GotoSlide (slide)

Worksheets("12RecvNew").Activate

'Grouping chart and copy to powerpoint

  For i = 1 To ActiveSheet.ChartObjects.Count
  Set cht = ActiveSheet.ChartObjects(i)
  Next i

 cht.Select
      ActiveChart.ChartArea.Copy


'PPApp.ActiveWindow.View.GotoSlide PPSlide.SlideIndex

Set PPSlide = PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)
With PPSlide
' paste and select the chart picture
.Shapes.Paste.Select
' align the chart
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
End With

' Clean up
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing

End Function

##'我在ActiveChart.ChartArea.Copy中遇到问题。它给了我错误:复制图表区域的方法失败##

我也试过这个,但它也不起作用:

ActiveSheet.Shapes.Range(Array("Chart 5", "Chart 6")).Select
Selection.ShapeRange.Group.Select
With ActiveSheet.ChartObjects.ShapeRange.Group
    .CopyPicture Appearance:=xlScreen, Format:=xlPicture
    .Ungroup
End With

0 个答案:

没有答案