Excel data into PowerPoint slides
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
The PowerPoint Add-In Excel Import can import Excel data to PowerPoint
What it does
- imports Excel data to your open presentation
Method: One Excel row per PowerPoint slide, one cell per text field on the current slide - can choose the Excel sheet to take data from if multiple sheets are present
- can automatically add slides if your Excel file has more rows than slides in Powerpoint
- warns you if there aren't enough text fields (shapes) to contain all data from a row
- works with every Microsoft Office version
How to use
- Download the Add-In
- save it in your Micorsoft Office Add-In folder
Tip: press Win+R and type %AppData%\Roaming\Microsoft\AddIns - Open PowerPoint and enable the Add-In
- Excel 2003: Menubar → Tools → Add-ins
- Excel 2007: Start-button → Excel Options → Add-Ins → drop down: Excel add-ins → Go
- Excel 2010: File tab → Options → Add-Ins → drop down: Excel add-ins → Go
If you have enough text fields, the Add-In will fill them
View this short imgur album to illustrate the Add-in
Note: If want to customize the code you have to add a registry key to see the Add-In code.
The source code can be viewed on pastebin