Mac – Excel data into PowerPoint slides

automationmacrosmicrosoft-excel-2011microsoft-powerpoint

I have already found some helpful sites but I'm still unable to do what I want. My Excel file contains few columns and multiple rows. All the data from one row would be in one slide but data from different cells in that one row should go to a specific elements in PP slide. At first, is it possible to export data from an Excel cell into a specific text box in PP? For example, I would like to have all data from the first column of each row go to a Text box 1. Let's say I have 100 rows so I would have 100 slides and each slide would have Text bow 1 with correct data. Text box of slide 66 would have data from the first column of row 66. Then all data from the second column of each row would go to a text bow 2 and so on.

I tried to do some macros with bad success. I also tried to use Word outlines and export them into PP (New slide -> Slides from Outline) but there seems to be a bug since I got 250 pages of gibberish. I had only two paragraphs and both had one word. First paragraph used Heading 1 style and second paragraph used Normal style.

Sites what I have found, use VB and/or some other programming language to create slides from Excel sheets. I have tried to add those VB codes into my macros but none of them hasn't worked so far. Probably I just don't know how to use them correctly 🙂 Here's some helpful sites:

VBA: Create PowerPoint Slide for Each Row in Excel Workbook

Creating a Presentation Report Based on Data

Question in Stackoverflow

I use Office 2011 on Mac. Any help would be appreciated!

Best Answer

Try something like this. I've made a few mods so that it replaces any instance of the text @COL1@ on the slide with values from the worksheet. Untested aircode, mind you.

Sub CreateSlides()
'Open the Excel workbook. Change the filename here.
Dim OWB As New Excel.Workbook
Set OWB = Excel.Application.Workbooks.Open("C:\list.xlsx")
'Grab the first Worksheet in the Workbook
Dim WS As Excel.Worksheet
Dim sCurrentText As String
Dim oSl As Slide
Dim oSh As Shape
Set WS = OWB.Worksheets(1)
Dim i As Long
'Loop through each used row in Column A
For i = 1 To WS.Range("A65536").End(xlUp).Row
    'Copy the first slide and paste at the end of the presentation
    ActivePresentation.Slides(1).Copy
    Set oSl = ActivePresentation.Slides.Paste(ActivePresentation.Slides.Count + 1)
    sCurrentText = WS.Cells(i, 1).Value

    ' find each shape with "@COL1@" in text, replace it with value from worksheet
    For Each oSh In oSl.Shapes
      ' Make sure the shape can hold text and if is, that it IS holding text
      If oSh.HasTextFrame Then
        If oSh.TextFrame.HasText Then
          ' it's got text, do the replace
          With oSh.TextFrame.TextRange
            .Replace "@COL1@", sCurrentText
          End With
        End If
      End If
    Next
Next
End Sub
Related Question