PDA

View Full Version : PowerPoint crashes while copypasting diagrams from Excel



Pavel1
04-11-2014, 07:01 AM
Sorry for my English

I have the following problem: while copypasting diagrams from Excel files to presentation, PowerPoint suddenly crushes. One of people I talked to said the problem was with .paste method, though I'm not sure about it. And I can't find any solution on the internet.

Function I use to paste graphs:


Function CopyGraphs(CurrentSlidePosition As Integer, CurrentWorkbook As Workbook, newPowerPoint As PowerPoint.Application) As Integer

Dim CurrentSheet As Worksheet

For Each CurrentSheet In CurrentWorkbook.Worksheets
CurrentSlidePosition = CurrentSlidePosition + 1
newPowerPoint.ActivePresentation.Slides(1).Duplicate
newPowerPoint.ActivePresentation.Slides(2).MoveTo toPos:=CurrentSlidePosition
CurrentSheet.ChartObjects(1).Copy
newPowerPoint.ActiveWindow.View.GotoSlide CurrentSlidePosition
newPowerPoint.ActivePresentation.Slides(CurrentSlidePosition).Select
newPowerPoint.ActivePresentation.Slides(CurrentSlidePosition).Shapes("Graph").Select
newPowerPoint.ActivePresentation.Windows(1).View.Paste
newPowerPoint.ActivePresentation.Slides(CurrentSlidePosition).Shapes("Title").TextFrame.TextRange.Text = "Some text"
Next

CopyGraphs = CurrentSlidePosition

End Function

Archive with files is attached: 11554. To execute it, you need to open Macro.xlsm and click the only button on the sheet
PP crashes only on Windows. It works fine on Mac.

Thanks in advance!