PDA

View Full Version : Help needed!! Cut and paste slides based on specific header/footers.



IndiK_W
01-27-2016, 06:16 AM
Hi all

I was hoping someone could help. In my powerpoint I have 9 slides. The nine slides have 3 topics (3 slides per topic).

What I want to be able to do is create a macro where I can move any one of the three topics (i.e. 3 slides per topic) to the top.

At the moment I have a macro that cuts and pastes the slides 4 to 6 (i.e. topic 2) to the top. The issue is that once that happens the other slides change place (so I cant know where the other 2 topics are exactly without looking).

Does anyone have a code where they can search for slides based on specific headers/footers and then cut and paste all slides that have that specific header/footer at the top of the deck?

So if I then have 3 slides with a header called Apple, 3 slides called Orange and 3 slides call Pear I can search for their name, cut them and copy them to the top

This is what I have currently


Sub Test()
Presentations("CV Deck").Slides.Range(Array(4,5, 6)).Cut

ActivePresentation.Slides.Paste 1

End Sub

John Wilson
01-27-2016, 06:58 AM
Best not to cut & paste see if this does it


Sub moveEm()
' change to suit search
Const strTitle As String = "Pear"
Dim rayTarget() As Long
Dim lngCounter As Long


'find and add to array
ReDim rayTarget(1 To 1)
For lngCounter = 1 To ActivePresentation.Slides.Count
If ActivePresentation.Slides(lngCounter).Shapes.HasTitle Then
If UCase(ActivePresentation.Slides(lngCounter).Shapes.Title.TextFrame2.TextRan ge) = UCase(strTitle) Then
rayTarget(UBound(rayTarget)) = ActivePresentation.Slides(lngCounter).SlideIndex
ReDim Preserve rayTarget(1 To UBound(rayTarget) + 1)
End If
End If
Next lngCounter
'strip last (blank) entry
ReDim Preserve rayTarget(1 To UBound(rayTarget) - 1)
'move slides in array
ActivePresentation.Slides.Range(rayTarget).MoveTo 1
End Sub

IndiK_W
01-27-2016, 07:22 AM
Thanks John

That was fantastic!! Much appreciated

John Wilson
01-27-2016, 01:21 PM
Interesting too because if you do the obvious thing and loop through the slides moving or cut and paste you tend to end up moving slides multiple times.