+ Reply to Thread
Results 1 to 14 of 14

Creating PowerPoint Presentation with VBA Fails Randomly

  1. #1
    Forum Contributor
    Join Date
    04-05-2010
    Location
    Lakewood, IL
    MS-Off Ver
    Excel 2016
    Posts
    384

    Creating PowerPoint Presentation with VBA Fails Randomly

    Hi, There is one has me really baffled.

    I wrote VBA code that creates a Power Point presentation. It goes through 2 tabs on excel workbook. It..

    1. Copies a chart and pastes it it PPT right justified
    2. Copies a picture and Pastes it to PPT left justified
    3. Copies some text and names each slide top-Center aliened.

    The VBA code randomly fails before it is finished, though it some times does complete the 6 total pages. Here are the errors I get:

    .Shapes.Paste.Select
    Error Message:
    PasteError.PNG or
    PasteError.PNG

    I also get a similar error when I copy a graphic.

    Selection.CopyPicture


    I have attached the Workbook with the VBA code.

    You may have to run the code several times before it will fail, but it eventually will.

    Why does it randomly fail??
    Attached Files Attached Files

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Creating PowerPoint Presentation with VBA Fails Randomly

    I could not get the application to fail, but I have a fairly fast machine with a lot of RAM.

    The only suggestion I can offer is to add DoEvents after each paste. DoEvents causes Excel to stop execution until things catch up. It's sometimes needed when talking with other applications. What might be happening is that Excel is busy pasting and PowerPoint is busy being pasted when Excel comes across the next copy command in the loop.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Forum Contributor
    Join Date
    04-05-2010
    Location
    Lakewood, IL
    MS-Off Ver
    Excel 2016
    Posts
    384

    Re: Creating PowerPoint Presentation with VBA Fails Randomly

    Hi dflak, That certainly makes sense. I tried it and it did not seem to work, could it be I need to enter that command before the "Paste"?

  4. #4
    Forum Contributor
    Join Date
    04-05-2010
    Location
    Lakewood, IL
    MS-Off Ver
    Excel 2016
    Posts
    384

    Re: Creating PowerPoint Presentation with VBA Fails Randomly

    Hi dflak, I tried putting the DoEvents after and then before the paste and the code still fails always in different places.

  5. #5
    Forum Contributor
    Join Date
    04-05-2010
    Location
    Lakewood, IL
    MS-Off Ver
    Excel 2016
    Posts
    384

    Re: Creating PowerPoint Presentation with VBA Fails Randomly

    One more piece of information I have just discovered. When it fails I go to the PPT slide and manually paste whatever is on the clip board and the file I want to paste does paste correctly.

  6. #6
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Creating PowerPoint Presentation with VBA Fails Randomly

    I'll try it on a slower machine to see if I can duplicate the issue.

  7. #7
    Forum Contributor
    Join Date
    04-05-2010
    Location
    Lakewood, IL
    MS-Off Ver
    Excel 2016
    Posts
    384

    Re: Creating PowerPoint Presentation with VBA Fails Randomly

    Thanks for helping!!!

  8. #8
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Creating PowerPoint Presentation with VBA Fails Randomly

    I ran it on my slower machine. It ran slower, but I still can't get it to fail.

    Another thought I have is that something else might be competing for the windows clipboard at the same time. My first thought was that it was competing with itself which is why I suggested DoEvents.

    A bit off topic. I have a similar program where I provide a "template" presentation. It is not a real template, it's a "blank" presentation with the "boilerplate" in place. I use an Excel Table to tell the program what excel sheet to go to, what range or chart to copy, which page to put it on in the presentation, where to locate it and how to size it. It works well with "fixed" templates which fortunately, most of my work is.

    I am looking at your code with an eye to create a presentation, "from scratch" adding slides as I go along.

  9. #9
    Forum Contributor
    Join Date
    04-05-2010
    Location
    Lakewood, IL
    MS-Off Ver
    Excel 2016
    Posts
    384

    Re: Creating PowerPoint Presentation with VBA Fails Randomly

    Thanks dflak, I have run it on two computers one that is really fast with a 6 core i5 processor and one with a slower AMD processor. Both have 8GB RAM and it fails on both!

  10. #10
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Creating PowerPoint Presentation with VBA Fails Randomly

    Have you tried to put DoEvents after the Copy?
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  11. #11
    Forum Contributor
    Join Date
    04-05-2010
    Location
    Lakewood, IL
    MS-Off Ver
    Excel 2016
    Posts
    384

    Re: Creating PowerPoint Presentation with VBA Fails Randomly

    Hi MarvinP, Yes I did both before and after with no improved results.

  12. #12
    Forum Contributor
    Join Date
    04-05-2010
    Location
    Lakewood, IL
    MS-Off Ver
    Excel 2016
    Posts
    384

    Re: Creating PowerPoint Presentation with VBA Fails Randomly

    Is there a way to turn off the screen updating of PowerPoint? The computer work very hard at showing you what is going on with PowerPoint. a comand like:
    Please Login or Register  to view this content.

  13. #13
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Creating PowerPoint Presentation with VBA Fails Randomly

    I took a deeper look into your code and I found a difference in how you paste in this application and how I paste in my application

    You
    Please Login or Register  to view this content.
    Me
    Please Login or Register  to view this content.
    Also I am attaching my application (with documentation). I suggest that you might want to use an excel table to drive what gets copied and where it gets pasted and positioned and sized, rather than repeat it in the code. I would be interested in doing a "hybrid" application using your techniques for adding sheets as needed and my reading specifications from an Excel Table.
    Attached Files Attached Files

  14. #14
    Forum Contributor
    Join Date
    04-05-2010
    Location
    Lakewood, IL
    MS-Off Ver
    Excel 2016
    Posts
    384

    Re: Creating PowerPoint Presentation with VBA Fails Randomly

    Hi dflak, Let me look at what you did and see how it applies to what I am doing. One thing I did notice is the chart is pasted as a picture not as an editable chart. I need the ability to have the user be able to modify the chart eliminates.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VBA PowerPoint update charts in presentation
    By SamGeron in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-14-2015, 08:19 AM
  2. VBA Transfer Range from Excel to Powerpoint (New or Existing Powerpoint Presentation)
    By ThePeoplesClub in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-14-2014, 02:52 PM
  3. Automatic powerpoint presentation
    By young_86 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-20-2013, 11:20 AM
  4. Replies: 13
    Last Post: 01-11-2013, 04:46 PM
  5. Chartsheets to PowerPoint presentation using VBA
    By mhuddles1981 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 06-01-2010, 12:57 PM
  6. powerpoint presentation in subform
    By Sonyk in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 07-25-2009, 04:26 PM
  7. PowerPoint Presentation in Excel
    By mehare in forum Excel General
    Replies: 1
    Last Post: 09-01-2006, 11:56 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1