none
Powerpoint 2016 crashes while copy pasting charts/graphs/objects from Excel 2016 - Excel VBA RRS feed

  • Question

  • I am using the below code for copy-pasting Charts/Graphs from Excel 2016 to Powerpoint 2016. While trying to do so, the Powerpoint crashes and i get an error. However, the funny part is, this code is used in many places and at times the code works and it breaks at random. i.e at times it works, at times it doesn't.

    Solution tried out: I tried adding a sleep (100) before pasting the object.

                                   Changing the hardware acceleration for ppt, excel and desktop.

                                   Re-Compiling the code in Excel 2016.

                                   Removing and adding the reference again in Excel 2016.

    All these efforts were of no help.

    VBA Code:

    With objPPt.ActivePresentation
                .Slides(ploc).Select
                .Slides(ploc).Shapes.Paste.Select

                DoEvents
                With objPPt.ActiveWindow.Selection.ShapeRange
                    .LockAspectRatio = False
                    .Width = w
                    .Height = h
                    .Left = l
                    .Top = t
                    .ZOrder (msoSendToBack)
                End With
                count = 1
    End With

    I am using VBA coded in Office 2016 on a windows 10 Desktop.

    The above code works perfectly fine with office 2013 - windows 7 desktop.

    Kindly help me out with the same. I have been searching for a viable solution since almost 2 months and not finding any.

    Thanks in advance.

    Monday, November 14, 2016 2:50 AM

All replies

  • Hi Anton

    I'm really not sure if you are facing the same issue as I did but let me share my findings.

    I used macro code to copy and paste elements from one PowerPoint presentation to another. Sometimes the pasting failed with a runtime error saying something like "no content available in the clipboard" (I don't remember the exact message). This happened very randomly and rarely only. I wasn't able to come up with an explanation.

    When continuing code execution after the error message, everything worked fine. So I guess the clipboard somehow was not ready when the VBA code already continued to the next line and called the Paste-method.

    By testing I noticed that the error does not occur anymore after I added "DoEvents" right before calling the Paste-method. Maybe you want to give it a try as well?

    Cheers, Luca

    There was no explanation   In my code the Copy method was just called in the line

    Monday, November 14, 2016 12:34 PM
  • Hi Luca,

              Thanks a lot for your inputs. However, I am already using a "DoEvents" before the copy and paste functions. :(

               In my case, the PPT is crashing and closing in between copy pasting and the excel macro breaks (with Run-time error ‘462’: The remote server machine does not exist or is unavialiable) since it is not able to find the destination PPT to paste it.

    Thanks and regards,

    Anton John

    Thursday, November 17, 2016 5:03 AM
  • Hi,

    Sorry that we failed to reproduce your issue.

    According to the error, please visit Excel automation fails second time code runs, you could find:

    This behavior is by design.

    To resolve this problem, modify the code so each call to an Excel object, method, or property is qualified with the appropriate object variable

    I think you need to check the code your refer to the Excel object, and do some adjustment.

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, November 21, 2016 9:17 AM
    Moderator
  • Hi Anton,

    Have you found solution to this issue?

    I also faced the same issue and DoEvents doesn't solve the issue.

    I used application.wait to wait for 3 seconds. looks like it's working. but it takes too much time cause I have 100+ objects to paste in powerpoint.

    Let me know if you have any better solution.

    Thank You in advance

    Regards,
    Ratna

    Wednesday, March 14, 2018 3:33 AM