Results 1 to 4 of 4

Copying data from Excel to PowerPoint skips steps

Threaded View

  1. #1
    Registered User
    Join Date
    02-14-2017
    Location
    Hilversum, Netherlands
    MS-Off Ver
    2010
    Posts
    92

    Copying data from Excel to PowerPoint skips steps

    Hi everyone!

    I am using Excel VBA to copy and paste data to a PowerPoint presentation. The data copies titles, text and tables from Excel into PowerPoint. Ever since I have added more steps to it, for some reason it skips multiple steps. It does select the tables, but for some reason it does not update them. When I go through the code step by step with F8 it does work for some reason. Please help out!

    You can find the code here:

    Sub Excel_PowerPoint_deck()
    
    Dim sh                  As Worksheet
    Dim saveAs              As String
    Dim savePath            As String
    Dim I                   As Integer
    Dim PowerPointApp       As PowerPoint.Application
    Dim ppPres              As PowerPoint.Presentation
    Dim PowerPointTable     As PowerPoint.Shape
    Dim DestinationPPT      As String
    
    Set sh = ActiveWorkbook.Sheets("Sheet1") '--------> aanpassen!
    Application.ScreenUpdating = False
    
    sh.Activate
        
    '    On Error Resume Next
        'If PowerPoint is not already open then open PowerPoint
        Set PowerPointApp = GetObject(, "Powerpoint.Application")
        
        If PowerPointApp Is Nothing Then
            Set PowerPointApp = CreateObject("PowerPoint.Application")
            PowerPointApp.Visible = True
        End If
    
        DestinationPPT = Range("E30").Value
        
        PowerPointApp.Presentations.Open (DestinationPPT)
        
        PowerPointApp.ActivePresentation.Slides(3).Select
        
    '-------------------------- TITEL -----------------------------------------
      'Pastes the information in the PowerPoint template
            PowerPointApp.ActivePresentation.Slides(3).Shapes(2).TextFrame.TextRange.Text = sh.Range("E5").Value
    
    
    ' find on Slide Number 1 which object ID is of Table type (you can change to whatever slide number you have your table)
    With PowerPointApp.ActivePresentation.Slides(3).Shapes
        For I = 1 To .Count
            If .Item(I).HasTable Then
                ShapeNum = I
            End If
        Next
    End With
    
    '-------------------------- Tabel 1 -----------------------------------------
    Set PowerPointTable = PowerPointApp.ActivePresentation.Slides(3).Shapes(ShapeNum - 2)
        
    ' copy range from Excel sheet
    Range("E9:G11").Copy
    
    ' select the Table cell you want to copy to >> modify according to the cell you want to use as the first Cell
    PowerPointTable.Table.Cell(1, 1).Shape.Select
    
    ' paste into existing PowerPoint table - use this line if you want to use the PowerPoint table format
    PowerPointApp.CommandBars.ExecuteMso ("PasteExcelTableDestinationTableStyle")
    'PowerPointApp.CommandBars.ExecuteMso ("PasteExcelChartSourceFormatting")
    
    Application.CutCopyMode = False
      Application.Wait (Now() + TimeValue("0:00:04"))
    
    
    '-------------------------- Tabel 2 -----------------------------------------
    
    Set PowerPointTable = PowerPointApp.ActivePresentation.Slides(3).Shapes(ShapeNum - 1)
    
    
    ' copy range from Excel sheet
    Range("M9:O11").Copy
    
    
    ' select the Table cell you want to copy to >> modify according to the cell you want to use as the first Cell
    PowerPointTable.Table.Cell(1, 1).Shape.Select
    
    ' paste into existing PowerPoint table - use this line if you want to use the PowerPoint table format
    PowerPointApp.CommandBars.ExecuteMso ("PasteExcelTableDestinationTableStyle")
    'PowerPointApp.CommandBars.ExecuteMso ("PasteExcelChartSourceFormatting")
    
    
    Application.CutCopyMode = False
      Application.Wait (Now() + TimeValue("0:00:06"))
    
    '-------------------------- Tabel 3 -----------------------------------------
    Set PowerPointTable = PowerPointApp.ActivePresentation.Slides(3).Shapes(ShapeNum)
    
    ' copy range from Excel sheet
    Range("T9:V11").Copy
    
    ' select the Table cell you want to copy to >> modify according to the cell you want to use as the first Cell
    PowerPointTable.Table.Cell(1, 1).Shape.Select
    
    ' paste into existing PowerPoint table - use this line if you want to use the PowerPoint table format
    PowerPointApp.CommandBars.ExecuteMso ("PasteExcelTableDestinationTableStyle")
    'PowerPointApp.CommandBars.ExecuteMso ("PasteExcelChartSourceFormatting")
    
    Application.CutCopyMode = False
    
    Filename = sh.Range("E31").Value
    
    ChDir (ThisWorkbook.Path)
    PowerPointApp.ActivePresentation.saveAs Filename
    
    PowerPointApp.ActivePresentation.Close
    
    End Sub
    For some reason I cannot upload the PowerPoint, but it is a very simple PPT template with a title and 3 tables.

    Thank you for your help!
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copying data from excel to Powerpoint
    By chrisellis250 in forum PowerPoint Formatting & General
    Replies: 1
    Last Post: 04-09-2019, 01:06 PM
  2. Copying data from Excel to PowerPoint as text or table
    By BillDoor in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-01-2016, 04:12 AM
  3. Data input in powerpoint to select data in excel and report back to powerpoint
    By daveybright in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-10-2009, 09:54 PM
  4. Copying Data From Excel to a Powerpoint Presentation
    By Vishal Dsouza in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-27-2007, 10:54 AM
  5. Copying Data From Excel to a Powerpoint Presentation
    By Vishal Dsouza in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-27-2007, 08:48 AM
  6. copying data in steps
    By nmatia in forum Excel General
    Replies: 3
    Last Post: 04-21-2007, 10:31 AM
  7. [SOLVED] copying data from Powerpoint to Excel
    By DB in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-09-2005, 12:05 PM

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