Error in script which copies charts from Excel to PowerPoint

前端 未结 3 1140
渐次进展
渐次进展 2021-01-16 15:24

I am attempting to call the below Sub in order to copy given chart to a specified PowerPoint presentation. However, when I run the macro which calls this Sub, the line indic

3条回答
  •  春和景丽
    2021-01-16 16:02

    I have had a lot of trouble in recent versions of Office. 2003 and earlier didn't have this problem, 2007 and 2010 had it a bit, and 2013 and 2016 have it in spades.

    When you step through the code it works fine, but when you run it at full speed, it errors on the paste.

    It's as if the copy doesn't have time to finish finish, so when you paste the clipboard doesn't have anything in it yet to paste.

    Sometimes this helps:

    chrt.CopyPicture Appearance:=xlScreen, Format:=xlBitmap
    DoEvents
    curSlide.Shapes.Paste
    

    DoEvents tells VBA to wait while background operations have a chance to finish up.

提交回复
热议问题