Skip to content

Instantly share code, notes, and snippets.

@marceloszilagyi
Created November 1, 2017 21:57
Show Gist options
  • Save marceloszilagyi/c5c32131ba28cce9d4c40309cfeb2b66 to your computer and use it in GitHub Desktop.
Save marceloszilagyi/c5c32131ba28cce9d4c40309cfeb2b66 to your computer and use it in GitHub Desktop.
Add text to existing shapes from Excel
Sub Add_Text_Excel_loop()
' Reference: http://www.vbaexpress.com/forum/showthread.php?43287-Loop-to-Copy-Text-From-Excel-to-Powerpoint-Text-Boxes
sn = GetObject("C:\Users\Excelfile.xlsm").sheets(1).Range("O1:S150") 'reference to an Excel file
ActiveWindow.View.GotoSlide Index:=1 ' go to slide number one
' here is the manual input to 50 slides
For j = 1 To 50
' update number in top left
ActivePresentation.Slides(j).Shapes("Shape 1").TextFrame.TextRange.Text = j
' update title - in my case, my excel file jumps from 3 to 3 lines, so that's why j times 3 (j *3)
ActivePresentation.Slides(j).Shapes("Title 1").TextFrame.TextRange.Text = sn(j * 3, 5)
'update callbox of impact of %NS
ActivePresentation.Slides(j).Shapes("Rectangular Callout 6").TextFrame.TextRange.Text = sn(j * 3, 1)
Next
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment