You are on page 1of 1

Sub Combinar()

Dim shtParticipantes As Worksheet


Dim strParticipante As String
Dim filaInicial As Long
Dim objPPT As Object
Dim objPres As Object
Dim objSld As Object
Dim objShp As Object

Set shtParticipantes = Worksheets("Participantes")

Set objPPT = CreateObject("Powerpoint.Application")


objPPT.Visible = True
Set objPres = objPPT.presentations.Open(ThisWorkbook.Path & "\diploma.pptx")
objPres.SaveAs ThisWorkbook.Path & "\combinados.pptx"

filaInicial = 2
Do While shtParticipantes.Cells(filaInicial, 1) <> ""
strParticipante = shtParticipantes.Cells(filaInicial, 1)

Set objSld = objPres.slides(1).Duplicate


For Each objShp In objSld.Shapes
If objShp.HasTextFrame Then
If objShp.TextFrame.hastext Then
objShp.TextFrame.TextRange.Replace "<nombre>", strParticipante
End If
End If
Next
filaInicial = filaInicial + 1
Loop
objPres.slides(1).Delete
objPres.Save
objPres.Close

End Sub

You might also like