bbrimberry
New Member
- Joined
- Mar 23, 2016
- Messages
- 34
Hello best VBAers around.
I have a ppt presentation I am opening from excel.
I have a Customer textbox on each slide.
I'd like to make a new presentation when the customer changes.
Any help would be greatly appreciated
I have a ppt presentation I am opening from excel.
I have a Customer textbox on each slide.
I'd like to make a new presentation when the customer changes.
Any help would be greatly appreciated
VBA Code:
Sub differentpptfiles()
Dim pptApp As PowerPoint.Application
Set pptApp = New PowerPoint.Application
Dim pptPres As PowerPoint.Presentation
Set pptPres = pptApp.Presentations.Open("myfile.pptx")
Dim slide As PowerPoint.slide
Dim currentValue As String
For Each slide In pptPres.Slides
' Check the value of the text box
Dim textBoxValue As String
textBoxValue = slide.Shapes("Customer").TextFrame.TextRange.Text
' If the value of the text box has changed, create a new presentation
If textBoxValue <> currentValue Then
' Create a new PowerPoint presentation
Dim newPres As PowerPoint.Presentation
Set newPres = pptApp.Presentations.Add
' Add the slide to the new presentation
' newPres.Slides.AddSlide 1, ppLayoutTitle
' not sure what should go here
' Save the new presentation with a unique name
newPres.SaveAs "C:\Users\name\Desktop\PowerPoint Loop\My Presentation " & currentValue & ".pptx"
' Close the new presentation
newPres.Close
' Update the current value of the text box
currentValue = textBoxValue
End If
Next slide
End Sub