1

I have several ppt files I need to spilt into smaller files. I am opening the ppt files from excel

Each file has a customer textbox. At each change in the customer textbox I'd like make ppt files based on the customer. Here's what I have so far I'm unsure about the lines that add the files to the new presentation. Any help is greatly appreciated

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

Ive tried the posted code. I think where I need help is below the line

    ' Add the slide to the new presentation
braX
  • 11,506
  • 5
  • 20
  • 33
brimberryb
  • 11
  • 1

1 Answers1

0

First copy the range Slides.range you need to put in the new presentation to the clipboard like

pptPress.slides.range().copy

Then you paste it into the slides collection of the new presentation

newPress.slides.paste

Slides.paste

wrbp
  • 870
  • 1
  • 3
  • 9