PDA

View Full Version : stuck after hours of research...sorting powerpoint slides



flashmpx
12-08-2011, 04:00 PM
Hi,

I would like to sort slides based on comparisons.

For example, let's say I have Slide A with Title 'ABCD' in a 44 page powerpoint present. I would like to look at the Title of every single slide, and IF it finds Slide B with Title 'XYZ', to move Slide A before Slide B.

Is this possible?

I've managed to find and modify some VBA code. However, when I execute it, it moves Slide "ABCD - Initiation" as the slide of the 44 page deck, when in reality, I want to move it after Slide "ISAC - Initiation"

How can I modify the code to make it do what I ask in my first paragraph? Any help would be greatly appreciated.


Sub bbbelu_orst()
Dim SldNum As Integer
Dim ChngFlag As Boolean
Dim NumRuns As Integer
ChngFlag = False
With ActivePresentation
LoopBack:
For SldNum = 1 To .Slides.Count - 1
If .Slides(SldNum).Shapes.HasTitle = msoTrue And .Slides(SldNum + 1).Shapes.HasTitle = msoTrue Then
If CStr(.Slides(SldNum).Shapes.Placeholders(1).TextFrame.TextRange.Text = "ABCD – Initiation") > CStr(.Slides(SldNum + 1).Shapes.Placeholders(1).TextFrame.TextRange.Text = "ISAC - Initiation") Then
ChngFlag = True
.Slides(SldNum).MoveTo (SldNum + 1)
End If
End If
If .Slides(SldNum + 1).Shapes.HasTitle = msoFalse Then
.Slides(SldNum + 1).MoveTo SldNum
End If
Next SldNum
NumRuns = NumRuns + 1
If NumRuns > 1000 Then
If MsgBox("Extended duration. Continue?", vbYesNo) <> vbYes Then Exit Sub
NumRuns = 0
End If
If ChngFlag = True Then
ChngFlag = False
GoTo LoopBack
End If

End With
MsgBox "Done."
End Sub

John Wilson
12-09-2011, 12:42 AM
Is there just one slide with each title?

If so

Sub Your_Move()
Dim osld As Slide
Dim FromSld As Slide
Dim ToSld As Slide
For Each osld In ActivePresentation.Slides
If osld.Shapes.HasTitle Then
'you should change the title text!
If osld.Shapes.Title.TextFrame.TextRange = "ghi" Then _
Set FromSld = osld
If osld.Shapes.Title.TextFrame.TextRange = "jkl" Then _
Set ToSld = osld
End If
Next osld
If Not ToSld Is Nothing And Not FromSld Is Nothing Then
FromSld.MoveTo (ToSld.SlideIndex - 1)
End If
End Sub

If there are more than one slide with each of the tables you need to say exactly how they should be ordered.

flashmpx
12-12-2011, 09:00 AM
Hi,

Thank you for your help thus far. I really appreciate it!

I had two additional questions based off of the macro that you provided me.

The first is, like you mentioned, if I have more than 1 title slide that has the same title. In this instance, how do I force the exact order?

Secondly, how to specify more than 2 orders. Do I just add additional line items ? For example, in your example, you have :

If osld.Shapes.Title.TextFrame.TextRange = "ISAC – Initiation" Then _
Set FromSld = osld
If osld.Shapes.Title.TextFrame.TextRange = "Release Health – Sales" Then _
Set ToSld = osld

How do I do more than two of these? I would like to essentially order 30-40~ slides. Do I just add additional IF statements following the same parameters above? Or is there a different format I need to specify?

Thanks again !!

flashmpx
12-12-2011, 09:16 AM
okay so i played around with the code a little bit and got a little further.

i think all i need help with is when there is more than 1 of the same title slide. in that scenario, is it possible to say, hey, do a check to see if there is more than 1 of the same title slide, AND if there are, then group them together in the same order, and then put slide "X" in front of those slides?

Heres what i came up with so far:

Sub Your_Move()
Dim osld As Slide
Dim FromSld As Slide
Dim ToSld As Slide
For Each osld In ActivePresentation.Slides

If osld.Shapes.HasTitle Then
'you should change the title text!

If osld.Shapes.Title.TextFrame.TextRange = "ISAC" Then _
Set FromSld = osld
If osld.Shapes.Title.TextFrame.TextRange = "ABCD" Then _
Set ToSld = osld

End If

Next osld

For Each osld In ActivePresentation.Slides

If osld.Shapes.HasTitle Then
If osld.Shapes.Title.TextFrame.TextRange = "QEFG" Then _
Set FromSld = osld
If osld.Shapes.Title.TextFrame.TextRange = "XVQ2" Then _
Set ToSld = osld

End If
Next osld

If Not ToSld Is Nothing And Not FromSld Is Nothing Then
FromSld.MoveTo (ToSld.SlideIndex - 1)
End If
End Sub

John Wilson
12-12-2011, 09:16 AM
What you need to do is explain how you would order them manually. ie What criteria would you use.

If two slides have the same title which comes first? (for example)

flashmpx
12-12-2011, 09:19 AM
what if i dont need any additional criteria. for example, i have PPT 1, and PPT2. The slides on PPT 1 have three title slides with the same title "ABCD", but they are in the correct order. Now I do a PPT merge, and its all in 1 PPT, and the slides are still in the correct order. Is it possible to say, keep them in the same order, but now just put slide "X" in front of that grouping?

John Wilson
12-12-2011, 10:02 AM
So do you want to move the three slides to be just behind slide X (slide x stays put) OR move slide x to be just in front of the three slide which stay where they are?