jwolf
12-14-2016, 11:24 PM
Hello!
I'm new to using the powerpoint library of VBA and I'm struggling with a project so if anyone has any advice or code samples I'd really appreciate it. I'm looking to take slides from an existing powerpoint, create a new powerpoint presentation with those slides, and then add textboxes and text to those slides. As an added complication, I need to take data from the excel sheet and create text on the created slides based on what that data says. Here is what I have so far. My question is how do I create textboxes and add text to the slides that I bring in using the insertfromfile method? I haven't assigned those slides as an object so the normal way of creating shapes doesn't make sense to me. I'm sure there's a way to do it but I'm not finding it... Would really love some help on this! Thanks!
Sub create_template()
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''
'Dimension variable and objects
Dim ppapp As PowerPoint.Application
Dim pppres As PowerPoint.Presentation
Dim ppslide As PowerPoint.Slide
Dim ppshape As Shape
Dim Var_x As String
Dim i As Integer
'Open Powerpoint
Set ppapp = CreateObject("Powerpoint.Application")
ppapp.Visible = True
Set pppres = ppapp.Presentations.Add
ppapp.ActiveWindow.ViewType = ppViewSlide
filepath = "C:\Users\jake"
'Create Card Deck
i = 1
j = 1
Do Until Sheet1.Cells(i + 1, 1).Value = "End"
Var_x = Sheet1.Cells(i + 1, 1).Value
If Var_x = "Option 1'" Then
pppres.Slides.InsertFromFile filepath & "ARC_doc", 0, 2, 2
ElseIf Var_x = "Option 2'" Then
pppres.Slides.InsertFromFile filepath & "ARC_doc", 0, 3, 3
ElseIf Var_x = "Option 3" Then
pppres.Slides.InsertFromFile filepath & "ARC_doc", 0, 4, 4
End If
i = i + 1
Loop
'Save Output File
With pppres
.SaveAs "C:\Users\jake\outputdoc.pptx"
.Close
End With
'Clean Up
ppapp.Quit
Set ppslide = Nothing
Set pppres = Nothing
Set ppapp = Nothing
End Sub
I'm new to using the powerpoint library of VBA and I'm struggling with a project so if anyone has any advice or code samples I'd really appreciate it. I'm looking to take slides from an existing powerpoint, create a new powerpoint presentation with those slides, and then add textboxes and text to those slides. As an added complication, I need to take data from the excel sheet and create text on the created slides based on what that data says. Here is what I have so far. My question is how do I create textboxes and add text to the slides that I bring in using the insertfromfile method? I haven't assigned those slides as an object so the normal way of creating shapes doesn't make sense to me. I'm sure there's a way to do it but I'm not finding it... Would really love some help on this! Thanks!
Sub create_template()
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''
'Dimension variable and objects
Dim ppapp As PowerPoint.Application
Dim pppres As PowerPoint.Presentation
Dim ppslide As PowerPoint.Slide
Dim ppshape As Shape
Dim Var_x As String
Dim i As Integer
'Open Powerpoint
Set ppapp = CreateObject("Powerpoint.Application")
ppapp.Visible = True
Set pppres = ppapp.Presentations.Add
ppapp.ActiveWindow.ViewType = ppViewSlide
filepath = "C:\Users\jake"
'Create Card Deck
i = 1
j = 1
Do Until Sheet1.Cells(i + 1, 1).Value = "End"
Var_x = Sheet1.Cells(i + 1, 1).Value
If Var_x = "Option 1'" Then
pppres.Slides.InsertFromFile filepath & "ARC_doc", 0, 2, 2
ElseIf Var_x = "Option 2'" Then
pppres.Slides.InsertFromFile filepath & "ARC_doc", 0, 3, 3
ElseIf Var_x = "Option 3" Then
pppres.Slides.InsertFromFile filepath & "ARC_doc", 0, 4, 4
End If
i = i + 1
Loop
'Save Output File
With pppres
.SaveAs "C:\Users\jake\outputdoc.pptx"
.Close
End With
'Clean Up
ppapp.Quit
Set ppslide = Nothing
Set pppres = Nothing
Set ppapp = Nothing
End Sub