Consulting

Results 1 to 2 of 2

Thread: Code for pasting Excel Tables to PowerPoint works with F8 but not when it is run with

  1. #1
    VBAX Regular sktneer's Avatar
    Joined
    Dec 2014
    Location
    Kanpur
    Posts
    6
    Location

    Code for pasting Excel Tables to PowerPoint works with F8 but not when it is run with

    I am experiencing a strange issue.

    I am trying to paste the data from Excel Tables into PowerPoint (existing presentation) as an editable Excel Tables. The code needs to work with the versions 2013 and 2010.
    I need to paste various Excel Tables into multiple PowerPoint Slides (25 slides).

    The code given below works fine with Excel 2013 but not with 2010.

    The issue is when I test the code with Excel 2010, it works fine when I debug the code with F8 and paste the Tables into PowerPoint Slides correctly but when I run the code at once the PowerPoint crashes and stops working.

    Shapes.Paste method works fine with Excel 2013 but doesn't paste anything when the code is run in Excel 2010 so I used Application.CommandBars.ExecuteMso ("PasteSourceFormatting") instead and this produced the desired output during debug.

    The code I am using is like this...

    Set ppSlide = ppPres.slides(2)
    ppSlide.Select
    
    If Sheets("Data").Range("H" & Sheets("Data").Range("A40").CurrentRegion.Rows.Count + 39).Value = 0 Then
       ppSlide.Shapes(2).TextFrame.TextRange.Text = "No relevant information is found."
    Else
    Set Rng = Sheets("Data").Range("A40").CurrentRegion
    Rng.Copy
    With ppSlide
      If ppApp.Version = 14 Then
         DoEvents
         .Application.CommandBars.ExecuteMso ("PasteSourceFormatting")
         Application.Wait Now + TimeValue("00:00:02")
      Else
         .Shapes.Paste
      End If
      .Shapes(3).Left = 45
      .Shapes(3).Top = 150
    End With
    End If
    Does anybody has an idea about how to deal with this?

    Any help would be greatly appreciated.

    Cross posted at ExcelForum.
    Regard
    sktneer

  2. #2
    VBAX Regular sktneer's Avatar
    Joined
    Dec 2014
    Location
    Kanpur
    Posts
    6
    Location
    Anybody???
    Regard
    sktneer

Posting Permissions

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