我正在尝试自动将报告从Excel发送到Powerpoint。我收到相同的错误消息。有时脚本可以工作,有些则不能。我在另一个线程中阅读了有关“ Panes”的内容,但我不知道该如何处理。导致错误的字符串是:
activeSlide.Shapes.PasteSpecial(DataType:= ppPasteBitmap).Select
我对编程不是很熟悉,因此请考虑一下。谢谢!
现在,我只是继续导出,并为无法使用的幻灯片进行了人工补偿。
'SLIDE HISTORICALS Germany _____________________________________________________________
'Add a new slide where we will paste the chart
newPowerPoint.ActivePresentation.Slides.Add newPowerPoint.ActivePresentation.Slides.Count + 1, ppLayoutText
newPowerPoint.ActiveWindow.View.GotoSlide newPowerPoint.ActivePresentation.Slides.Count
Set activeSlide = newPowerPoint.ActivePresentation.Slides(newPowerPoint.ActivePresentation.Slides.Count)
Sheets("Historicals Output").Activate
'Copy the chart and paste it into the PowerPoint as a Metafile Picture
ActiveWorkbook.Worksheets("Historicals Output").Range("A86:S118").Select
Selection.Copy
'''activeSlide.Shapes.PasteSpecial(DataType:= ppPasteBitmap)。选择'''
'Set the title of the slide the same as the title of the chart
' activeSlide.Shapes(1).TextFrame.TextRange.Text = cht.Chart.ChartTitle.Text
'Adjust the positioning of the Chart on Powerpoint Slide
' newPowerPoint.ActiveWindow.Selection.ShapeRange.Left = 15
newPowerPoint.ActiveWindow.Selection.ShapeRange.Top = 70
' create textbox
Sheets("Text").Activate
ActiveWorkbook.Worksheets("Text").Range("b12:z12").Select
Selection.Copy''' activeSlide.Shapes.PasteSpecial(DataType:=ppPasteBitmap).Select '''
newPowerPoint.ActiveWindow.Selection.ShapeRange.Top = 0
newPowerPoint.ActiveWindow.Selection.ShapeRange.Left = 0
我非常感谢您能顺利进行此操作。
答案 0 :(得分:0)
看看是否是这种情况。
将幻灯片粘贴到幻灯片上后,PowerPoint通常需要一些时间。
尤其是像Excel表这样的OLE对象需要一段时间。
尝试添加以下代码片段。
...
Selection.Copy
activeSlide.Shapes.PasteSpecial(DataType:=ppPasteBitmap)
'Let's give some break time
Do
DoEvents
Loop Until activeSlide.Shapes.Count > 0 ' use '0' if pasted on a new slide
'Select the last shape pasted
activeSlide.Shapes(activeSlide.Shapes.Count).Select
...